X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_do.c;h=46ca79b95a6e706d56af06c2e211d86799f54742;hb=0d26482f4c7e8cb5e811771c91e95007d0b78f3e;hp=671b9fa3f3b809f2a8850bdd47c699b53fca0654;hpb=571fad579922f2b10873193500dfd0652f4fdc37;p=awesomized%2Flibmemcached diff --git a/libmemcached/memcached_do.c b/libmemcached/memcached_do.c index 671b9fa3..46ca79b9 100644 --- a/libmemcached/memcached_do.c +++ b/libmemcached/memcached_do.c @@ -1,6 +1,6 @@ #include "common.h" -memcached_return memcached_do(memcached_server_st *ptr, const char *command, +memcached_return memcached_do(memcached_server_st *ptr, const void *command, size_t command_length, uint8_t with_flush) { memcached_return rc; @@ -10,13 +10,24 @@ memcached_return memcached_do(memcached_server_st *ptr, const char *command, WATCHPOINT_ASSERT(command); if ((rc= memcached_connect(ptr)) != MEMCACHED_SUCCESS) + { + WATCHPOINT_ERROR(rc); return rc; + } - sent_length= memcached_io_write(ptr, command, command_length, with_flush); + /* + ** Since non buffering ops in UDP mode dont check to make sure they will fit + ** before they start writing, if there is any data in buffer, clear it out, + ** otherwise we might get a partial write. + **/ + if (ptr->type == MEMCACHED_CONNECTION_UDP && with_flush && ptr->write_buffer_offset > UDP_DATAGRAM_HEADER_LENGTH) + memcached_io_write(ptr, NULL, 0, 1); - if (sent_length == -1 || sent_length != command_length) + sent_length= memcached_io_write(ptr, command, command_length, (char) with_flush); + + if (sent_length == -1 || (size_t)sent_length != command_length) rc= MEMCACHED_WRITE_FAILURE; - else + else if ((ptr->root->flags & MEM_NOREPLY) == 0) memcached_server_response_increment(ptr); return rc;