libmemcached/response.cc
/*
 * Fetching the piped responses : RESPONSE <count>\r\n
 * (works only for same kind of operations)
 */
Fetching the piped responses : RESPONSE \r\n
(works only for same kind of operations)
Fetching the piped responses : RESPONSE \ r \ n ( works only for same kind of operations )
static memcached_return_t textual_coll_piped_response_fetch(memcached_server_write_instance_st ptr, char *buffer,
                                                            size_t buffer_length)
{
#ifdef ENABLE_REPLICATION
  memcached_return_t switchover_rc= MEMCACHED_SUCCESS;
#endif
  memcached_return_t rc= MEMCACHED_SUCCESS;
  memcached_return_t *responses= ptr->root->pipe_responses;
  size_t i, offset= ptr->root->pipe_responses_length;
  uint32_t count[1];
  size_t total_read= 0;
  if (not parse_response_header(buffer, "RESPONSE", 8, count, 1))
  {
    return MEMCACHED_PARTIAL_READ;
  }
  for (i= 0; i< count[0]; i++)
  {
    rc= memcached_io_readline(ptr, buffer, buffer_length, total_read);
    if (rc != MEMCACHED_SUCCESS)
    {
      break;
    }
    rc= get_status_of_coll_pipe_response(ptr, buffer, total_read-2);
    if (rc == MEMCACHED_UNKNOWN_READ_FAILURE)
    {
      break;
    }
#ifdef ENABLE_REPLICATION
    if (rc == MEMCACHED_SWITCHOVER or rc == MEMCACHED_REPL_SLAVE)
    {
      switchover_rc= rc;
      rc= MEMCACHED_SUCCESS;
      break; 
    }
#endif
    responses[offset+i]= rc;
    aggregate_pipe_return_code(ptr->root, responses[offset+i], &ptr->root->pipe_return_code);
  }
  ptr->root->pipe_responses_length+= i; 
  if (i < count[0] && rc != MEMCACHED_SUCCESS)
  {
    return rc;
  }
  rc= memcached_io_readline(ptr, buffer, buffer_length, total_read);
  if (rc != MEMCACHED_SUCCESS)
  {
    return rc;
  }
  rc= get_status_of_coll_pipe_response(ptr, buffer, total_read-2);
#ifdef ENABLE_REPLICATION
  if (switchover_rc != MEMCACHED_SUCCESS && rc == MEMCACHED_PIPE_ERROR_BAD_ERROR) {
    return switchover_rc;
  }
#endif
  return rc;
}
static memcached_return_t textual_coll_piped_response_fetch ( memcached_server_write_instance_st ptr , char * buffer , size_t buffer_length ) { #ifdef ENABLE_REPLICATION memcached_return_t switchover_rc = MEMCACHED_SUCCESS ; #endif memcached_return_t rc = MEMCACHED_SUCCESS ; memcached_return_t * responses = ptr -> root -> pipe_responses ; size_t i , offset = ptr -> root -> pipe_responses_length ; uint32_t count [ 1 ] ; size_t total_read = 0 ; if ( not parse_response_header ( buffer , " " , 8 , count , 1 ) ) { return MEMCACHED_PARTIAL_READ ; } for ( i = 0 ; i < count [ 0 ] ; i ++ ) { rc = memcached_io_readline ( ptr , buffer , buffer_length , total_read ) ; if ( rc != MEMCACHED_SUCCESS ) { break ; } rc = get_status_of_coll_pipe_response ( ptr , buffer , total_read - 2 ) ; if ( rc == MEMCACHED_UNKNOWN_READ_FAILURE ) { break ; } #ifdef ENABLE_REPLICATION if ( rc == MEMCACHED_SWITCHOVER or rc == MEMCACHED_REPL_SLAVE ) { switchover_rc = rc ; rc = MEMCACHED_SUCCESS ; break ; } #endif responses [ offset + i ] = rc ; aggregate_pipe_return_code ( ptr -> root , responses [ offset + i ] , & ptr -> root -> pipe_return_code ) ; } ptr -> root -> pipe_responses_length += i ; if ( i < count [ 0 ] && rc != MEMCACHED_SUCCESS ) { return rc ; } rc = memcached_io_readline ( ptr , buffer , buffer_length , total_read ) ; if ( rc != MEMCACHED_SUCCESS ) { return rc ; } rc = get_status_of_coll_pipe_response ( ptr , buffer , total_read - 2 ) ; #ifdef ENABLE_REPLICATION if ( switchover_rc != MEMCACHED_SUCCESS && rc == MEMCACHED_PIPE_ERROR_BAD_ERROR ) { return switchover_rc ; } #endif return rc ; }
Fetching the piped responses : RESPONSE <count>\r\n
 (works only for same kind of operations)
Fetching the piped responses : RESPONSE <count > \ r \ n ( works only for same kind of operations )
/* Let's skip aggregate_pipe_return_code() */ /* i can be smaller than count[0] */ /* Pipe operation is stopped if switchover is done. */