{
if (ptr->fd != -1)
{
- if (io_death == 0)
+ if (io_death == 0 && ptr->type != MEMCACHED_CONNECTION_UDP)
{
memcached_return rc;
ssize_t read_length;
memcached_io_close(ptr);
ptr->fd= -1;
- ptr->write_buffer_offset= 0;
+ ptr->write_buffer_offset= (ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0 ;
ptr->read_buffer_length= 0;
ptr->read_ptr= ptr->read_buffer;
memcached_server_response_reset(ptr);