libmemcached/quit.cc
/*
  This closes all connections (forces flush of input as well).

  Maybe add a host specific, or key specific version?

  The reason we send "quit" is that in case we have buffered IO, this
  will force data to be completed.
*/
This closes all connections (forces flush of input as well).

The reason we send "quit" is that in case we have buffered IO, this
will force data to be completed.
This closes all connections ( forces flush of input as well ) . The reason we send " quit " is that in case we have buffered IO this will force data to be completed .
void memcached_quit_server(memcached_server_st *ptr, bool io_death)
{
  if (ptr->fd != INVALID_SOCKET)
  {
    if (io_death == false && ptr->type != MEMCACHED_CONNECTION_UDP && ptr->options.is_shutting_down == false)
    {
      ptr->options.is_shutting_down= true;
      memcached_return_t rc;
      if (ptr->root->flags.binary_protocol)
      {
        protocol_binary_request_quit request= {}; 
        request.message.header.request.magic = PROTOCOL_BINARY_REQ;
        request.message.header.request.opcode = PROTOCOL_BINARY_CMD_QUIT;
        request.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES;
        rc= memcached_do(ptr, request.bytes, sizeof(request.bytes), true);
      }
      else
      {
        rc= memcached_do(ptr, memcached_literal_param("quit\r\n"), true);
      }
      WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_FETCH_NOTFINISHED);
      if (ptr->root->flags.buffer_requests or ptr->root->number_of_replicas)
      {
        memcached_return_t rc_slurp;
        while (memcached_continue(rc_slurp= memcached_io_slurp(ptr))) {} ;
        WATCHPOINT_ASSERT(rc_slurp == MEMCACHED_CONNECTION_FAILURE);
      }
      ptr->server_failure_counter= 0;
    }
    memcached_io_close(ptr);
  }
  ptr->state= MEMCACHED_SERVER_STATE_NEW;
  ptr->cursor_active= 0;
  ptr->io_bytes_sent= 0;
  ptr->write_buffer_offset= (size_t) ((ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0);
  ptr->read_buffer_length= 0;
  ptr->read_ptr= ptr->read_buffer;
  ptr->options.is_shutting_down= false;
  memcached_server_response_reset(ptr);
  ptr->major_version= ptr->minor_version= ptr->micro_version= UINT8_MAX;
  ptr->is_enterprise= false;
  if (io_death)
  {
    memcached_mark_server_for_timeout(ptr);
  }
}
void memcached_quit_server ( memcached_server_st * ptr , bool io_death ) { if ( ptr -> fd != INVALID_SOCKET ) { if ( io_death == false && ptr -> type != MEMCACHED_CONNECTION_UDP && ptr -> options . is_shutting_down == false ) { ptr -> options . is_shutting_down = true ; memcached_return_t rc ; if ( ptr -> root -> flags . binary_protocol ) { protocol_binary_request_quit request = { } ; request . message . header . request . magic = PROTOCOL_BINARY_REQ ; request . message . header . request . opcode = PROTOCOL_BINARY_CMD_QUIT ; request . message . header . request . datatype = PROTOCOL_BINARY_RAW_BYTES ; rc = memcached_do ( ptr , request . bytes , sizeof ( request . bytes ) , true ) ; } else { rc = memcached_do ( ptr , memcached_literal_param ( " \r \n " ) , true ) ; } WATCHPOINT_ASSERT ( rc == MEMCACHED_SUCCESS or rc == MEMCACHED_FETCH_NOTFINISHED ) ; if ( ptr -> root -> flags . buffer_requests or ptr -> root -> number_of_replicas ) { memcached_return_t rc_slurp ; while ( memcached_continue ( rc_slurp = memcached_io_slurp ( ptr ) ) ) { } ; WATCHPOINT_ASSERT ( rc_slurp == MEMCACHED_CONNECTION_FAILURE ) ; } ptr -> server_failure_counter = 0 ; } memcached_io_close ( ptr ) ; } ptr -> state = MEMCACHED_SERVER_STATE_NEW ; ptr -> cursor_active = 0 ; ptr -> io_bytes_sent = 0 ; ptr -> write_buffer_offset = ( size_t ) ( ( ptr -> type == MEMCACHED_CONNECTION_UDP ) ? UDP_DATAGRAM_HEADER_LENGTH : 0 ) ; ptr -> read_buffer_length = 0 ; ptr -> read_ptr = ptr -> read_buffer ; ptr -> options . is_shutting_down = false ; memcached_server_response_reset ( ptr ) ; ptr -> major_version = ptr -> minor_version = ptr -> micro_version = UINT8_MAX ; ptr -> is_enterprise = false ; if ( io_death ) { memcached_mark_server_for_timeout ( ptr ) ; } }
This closes all connections (forces flush of input as well).
This closes all connections ( forces flush of input as well ) .
// = {.bytes= {0}}; /* read until socket is closed, or there is an error
       * closing the socket before all data is read
       * results in server throwing away all data which is
       * not read
       *
       * In .40 we began to only do this if we had been doing buffered
       * requests of had replication enabled.
       */ /*
       * memcached_io_read may call memcached_quit_server with io_death if
       * it encounters problems, but we don't care about those occurences.
       * The intention of that loop is to drain the data sent from the
       * server to ensure that the server processed all of the data we
       * sent to the server.
       */ // We reset the version so that if we end up talking to a different server // we don't have stale server version information.