memcached.c
static void complete_nread_ascii(conn *c) {
    assert(c != NULL);

    item *it = c->item;
    int comm = c->cmd;
    enum store_item_type ret;

    pthread_mutex_lock(&c->thread->stats.mutex);
    c->thread->stats.slab_stats[it->slabs_clsid].set_cmds++;
    pthread_mutex_unlock(&c->thread->stats.mutex);

    if (strncmp(ITEM_data(it) + it->nbytes - 2, "\r\n", 2) != 0) {
        out_string(c, "CLIENT_ERROR bad data chunk");
    } else {
      ret = store_item(it, comm, c);

#ifdef ENABLE_DTRACE
      uint64_t cas = ITEM_get_cas(it);
      switch (c->cmd) {
      case NREAD_ADD:
          MEMCACHED_COMMAND_ADD(c->sfd, ITEM_key(it), it->nkey,
                                (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_REPLACE:
          MEMCACHED_COMMAND_REPLACE(c->sfd, ITEM_key(it), it->nkey,
                                    (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_APPEND:
          MEMCACHED_COMMAND_APPEND(c->sfd, ITEM_key(it), it->nkey,
                                   (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_PREPEND:
          MEMCACHED_COMMAND_PREPEND(c->sfd, ITEM_key(it), it->nkey,
                                    (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_SET:
          MEMCACHED_COMMAND_SET(c->sfd, ITEM_key(it), it->nkey,
                                (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_CAS:
          MEMCACHED_COMMAND_CAS(c->sfd, ITEM_key(it), it->nkey, it->nbytes,
                                cas);
          break;
      }
#endif

      switch (ret) {
      case STORED:
          out_string(c, "STORED");
          break;
      case EXISTS:
          out_string(c, "EXISTS");
          break;
      case NOT_FOUND:
          out_string(c, "NOT_FOUND");
          break;
      case NOT_STORED:
          out_string(c, "NOT_STORED");
          break;
      default:
          out_string(c, "SERVER_ERROR Unhandled storage type.");
      }

    }

    item_remove(c->item);       /* release the c->item reference */
    c->item = 0;
}
/*
 * we get here after reading the value in set/add/replace commands. The command
 * has been stored in c->cmd, and the item is ready in c->item.
 */
we get here after reading the value in set/add/replace commands. The command
has been stored in c->cmd, and the item is ready in c->item.
we get here after reading the value in set / add / replace commands . The command has been stored in c - > cmd and the item is ready in c - > item .
static void complete_nread_ascii(conn *c) {
    assert(c != NULL);
    item *it = c->item;
    int comm = c->cmd;
    enum store_item_type ret;
    pthread_mutex_lock(&c->thread->stats.mutex);
    c->thread->stats.slab_stats[it->slabs_clsid].set_cmds++;
    pthread_mutex_unlock(&c->thread->stats.mutex);
    if (strncmp(ITEM_data(it) + it->nbytes - 2, "\r\n", 2) != 0) {
        out_string(c, "CLIENT_ERROR bad data chunk");
    } else {
      ret = store_item(it, comm, c);
#ifdef ENABLE_DTRACE
      uint64_t cas = ITEM_get_cas(it);
      switch (c->cmd) {
      case NREAD_ADD:
          MEMCACHED_COMMAND_ADD(c->sfd, ITEM_key(it), it->nkey,
                                (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_REPLACE:
          MEMCACHED_COMMAND_REPLACE(c->sfd, ITEM_key(it), it->nkey,
                                    (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_APPEND:
          MEMCACHED_COMMAND_APPEND(c->sfd, ITEM_key(it), it->nkey,
                                   (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_PREPEND:
          MEMCACHED_COMMAND_PREPEND(c->sfd, ITEM_key(it), it->nkey,
                                    (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_SET:
          MEMCACHED_COMMAND_SET(c->sfd, ITEM_key(it), it->nkey,
                                (ret == 1) ? it->nbytes : -1, cas);
          break;
      case NREAD_CAS:
          MEMCACHED_COMMAND_CAS(c->sfd, ITEM_key(it), it->nkey, it->nbytes,
                                cas);
          break;
      }
#endif
      switch (ret) {
      case STORED:
          out_string(c, "STORED");
          break;
      case EXISTS:
          out_string(c, "EXISTS");
          break;
      case NOT_FOUND:
          out_string(c, "NOT_FOUND");
          break;
      case NOT_STORED:
          out_string(c, "NOT_STORED");
          break;
      default:
          out_string(c, "SERVER_ERROR Unhandled storage type.");
      }
    }
    item_remove(c->item);       
    c->item = 0;
}
static void complete_nread_ascii ( conn * c ) { assert ( c != NULL ) ; item * it = c -> item ; int comm = c -> cmd ; enum store_item_type ret ; pthread_mutex_lock ( & c -> thread -> stats . mutex ) ; c -> thread -> stats . slab_stats [ it -> slabs_clsid ] . set_cmds ++ ; pthread_mutex_unlock ( & c -> thread -> stats . mutex ) ; if ( strncmp ( ITEM_data ( it ) + it -> nbytes - 2 , " \r \n " , 2 ) != 0 ) { out_string ( c , " " ) ; } else { ret = store_item ( it , comm , c ) ; #ifdef ENABLE_DTRACE uint64_t cas = ITEM_get_cas ( it ) ; switch ( c -> cmd ) { case NREAD_ADD : MEMCACHED_COMMAND_ADD ( c -> sfd , ITEM_key ( it ) , it -> nkey , ( ret == 1 ) ? it -> nbytes : -1 , cas ) ; break ; case NREAD_REPLACE : MEMCACHED_COMMAND_REPLACE ( c -> sfd , ITEM_key ( it ) , it -> nkey , ( ret == 1 ) ? it -> nbytes : -1 , cas ) ; break ; case NREAD_APPEND : MEMCACHED_COMMAND_APPEND ( c -> sfd , ITEM_key ( it ) , it -> nkey , ( ret == 1 ) ? it -> nbytes : -1 , cas ) ; break ; case NREAD_PREPEND : MEMCACHED_COMMAND_PREPEND ( c -> sfd , ITEM_key ( it ) , it -> nkey , ( ret == 1 ) ? it -> nbytes : -1 , cas ) ; break ; case NREAD_SET : MEMCACHED_COMMAND_SET ( c -> sfd , ITEM_key ( it ) , it -> nkey , ( ret == 1 ) ? it -> nbytes : -1 , cas ) ; break ; case NREAD_CAS : MEMCACHED_COMMAND_CAS ( c -> sfd , ITEM_key ( it ) , it -> nkey , it -> nbytes , cas ) ; break ; } #endif switch ( ret ) { case STORED : out_string ( c , " " ) ; break ; case EXISTS : out_string ( c , " " ) ; break ; case NOT_FOUND : out_string ( c , " " ) ; break ; case NOT_STORED : out_string ( c , " " ) ; break ; default : out_string ( c , " " ) ; } } item_remove ( c -> item ) ; c -> item = 0 ; }
we get here after reading the value in set/add/replace commands.
we get here after reading the value in set / add / replace commands .
/* release the c->item reference */