8000 centralize noreply code more · memcached/memcached@cae3949 · GitHub
[go: up one dir, main page]

Skip to content

Commit cae3949

Browse files
committed
centralize noreply code more
was double-checking for noreply since we now grab it during the initial parsing. defaults to allowing noreply and maybe some functions should force-disable it?
1 parent f25b8da commit cae3949

File tree

2 files changed

+2
-38
lines changed

2 files changed

+2
-38
lines changed

proto_parser.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,12 @@ static void pout_string(mc_resp *resp, const char *str) {
385385
bool skip = resp->skip;
386386
assert(resp != NULL);
387387

388-
// if response was original filled with something, but we're now writing
388+
// if response was originally filled with something, but we're now writing
389389
// out an error or similar, have to reset the object first.
390390
resp_reset(resp);
391391

392392
// We blank the response "just in case", but if we're not intending on
393393
// sending it lets not rewrite it.
394-
// 8000 FIXME: do noreply and skip need to be separate?
395394
if (skip || resp->noreply) {
396395
resp->skip = true;
397396
return;
@@ -742,7 +741,6 @@ item *process_update_cmd_start(LIBEVENT_THREAD *t, mcp_parser_t *pr, mc_resp *re
742741
item *it;
743742

744743
assert(resp != NULL);
745-
resp->noreply = pr->noreply;
746744

747745
if (nkey > KEY_MAX_LENGTH) {
748746
pout_string(resp, "CLIENT_ERROR bad command line format");
@@ -855,7 +853,6 @@ void process_arithmetic_cmd(LIBEVENT_THREAD *t, mcp_parser_t *pr, mc_resp *resp,
855853
size_t nkey = pr->klen;
856854

857855
assert(t != NULL);
858-
resp->noreply = pr->noreply;
859856

860857
if (nkey > KEY_MAX_LENGTH) {
861858
pout_string(resp, "CLIENT_ERROR bad command line format");
@@ -900,7 +897,6 @@ void process_delete_cmd(LIBEVENT_THREAD *t, mcp_parser_t *pr, mc_resp *resp) {
900897
uint32_t hv;
901898

902899
assert(t != NULL);
903-
resp->noreply = pr->noreply;
904900

905901
// NOTE: removed a compatibility bodge from a decade ago.
906902
// delete used to take a "delay" argument, which was removed, but some
@@ -947,7 +943,6 @@ void process_touch_cmd(LIBEVENT_THREAD *t, mcp_parser_t *pr, mc_resp *resp) {
947943
item *it;
948944

949945
assert(t != NULL);
950-
resp->noreply = pr->noreply;
951946

952947
if (nkey > KEY_MAX_LENGTH) {
953948
pout_string(resp, "CLIENT_ERROR bad command line format");

proto_text.c

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -388,26 +388,6 @@ int try_read_command_ascii(conn *c) {
388388
return 1;
389389
}
390390

391-
static inline bool set_noreply_maybe(conn *c, mcp_parser_t *pr) {
392-
int noreply_index = pr->tok.ntokens-1;
393-
394-
/*
395-
NOTE: this function is not the first place where we are going to
396-
send the reply. We could send it instead from process_command()
397-
if the request line has wrong number of tokens. However parsing
398-
malformed line for "noreply" option is not reliable anyway, so
399-
it can't be helped.
400-
*/
401-
if (noreply_index >= 0) {
402-
int len = 0;
403-
const char *noreply = mcmc_token_get(pr->request, &pr->tok, noreply_index, &len);
404-
if (strncmp(noreply, "noreply", 7) == 0) {
405-
c->resp->noreply = true;
406-
}
407-
}
408-
return c->resp->noreply;
409-
}
410-
411391
static void process_get_command_err(conn *c, const char *errstr) {
412392
// Use passed in error or rescue the last error while processing.
413393
char wbuf[WRITE_BUFFER_SIZE];
@@ -786,8 +766,6 @@ static void process_update_command(conn *c, mcp_parser_t *pr, mc_resp *resp, int
786766
static void process_verbosity_command(conn *c, mcp_parser_t *pr) {
787767
assert(c != NULL);
788768

789-
set_noreply_maybe(c, pr);
790-
791769
uint32_t level;
792770
if (mcmc_token_get_u32(pr->request, &pr->tok, 1, &level) != MCMC_OK) {
793771
out_string(c, "CLIENT_ERROR bad command line format");
@@ -891,8 +869,6 @@ static void process_slabs_automove_command(conn *c, mcp_parser_t *pr) {
891869

892870
assert(c != NULL);
893871

894-
set_noreply_maybe(c, pr);
895-
896872
const char *subcmd = mcmc_token_get(pr->request, &pr->tok, 2, &len);
897873
if (strncmp(subcmd, "ratio", len) == 0) {
898874
if (ntokens < 4 || !mc_toktod(pr, 3, &ratio)) {
@@ -1003,8 +979,6 @@ static void process_memlimit_command(conn *c, mcp_parser_t *pr) {
1003979
uint32_t memlimit;
1004980
assert(c != NULL);
1005981

1006-
set_noreply_maybe(c, pr);
1007-
1008982
if (mcmc_token_get_u32(pr->request, &pr->tok, 1, &memlimit) != MCMC_OK) {
1009983
out_string(c, "ERROR");
1010984
} else {
@@ -1036,8 +1010,6 @@ static void process_lru_command(conn *c, mcp_parser_t *pr) {
10361010
int ntokens = pr->tok.ntokens;
10371011
const char *subcmd = mcmc_token_get(pr->request, &pr->tok, SUBCOMMAND_TOKEN, &len);
10381012

1039-
set_noreply_maybe(c, pr);
1040-
10411013
if (strncmp(subcmd, "tune", len) == 0 && ntokens >= 6) {
10421014
if (!mc_toktou32(pr, 2, &pct_hot) ||
10431015
!mc_toktou32(pr, 3, &pct_warm) ||
@@ -1087,7 +1059,6 @@ static void process_lru_command(conn *c, mcp_parser_t *pr) {
10871059
}
10881060
#ifdef EXTSTORE
10891061
static void process_extstore_command(conn *c, mcp_parser_t *pr) {
1090-
set_noreply_maybe(c, pr);
10911062
bool ok = true;
10921063
int ntokens = pr->tok.ntokens;
10931064
int len = 0;
@@ -1157,8 +1128,6 @@ static void process_flush_all_command(conn *c, mcp_parser_t *pr) {
11571128
int32_t exptime = 0;
11581129
rel_time_t new_oldest = 0;
11591130

1160-
set_noreply_maybe(c, pr);
1161-
11621131
pthread_mutex_lock(&c->thread->stats.mutex);
11631132
c->thread->stats.flush_cmds++;
11641133
pthread_mutex_unlock(&c->thread->stats.mutex);
@@ -1436,7 +1405,6 @@ static void process_lru_crawler_command(conn *c, mcp_parser_t *pr) {
14361405
}
14371406
#ifdef TLS
14381407
static void process_refresh_certs_command(conn *c, mcp_parser_t *pr) {
1439-
set_noreply_maybe(c, pr);
14401408
char *errmsg = NULL;
14411409
if (refresh_certs(&errmsg)) {
14421410
out_string(c, "OK");
@@ -1522,6 +1490,7 @@ void process_command_ascii(conn *c, char *command, size_t cmdlen) {
15221490

15231491
t->cur_sfd = c->sfd; // cuddle sfd for logging.
15241492
int ret = process_request(&pr, command, cmdlen);
1493+
c->resp->noreply = pr.noreply;
15251494
if (settings.verbose > 1) {
15261495
fprintf(stderr, "<%d %.*s\n", t->cur_sfd, (int)cmdlen-2, command);
15271496
}

0 commit comments

Comments
 (0)
0