6 #include "protocol_extension.h"
8 static const char *get_name(
const void *cmd_cookie);
9 static bool accept_command(
const void *cmd_cookie,
void *cookie,
10 int argc,
token_t *argv,
size_t *ndata,
12 static ENGINE_ERROR_CODE execute_command(
const void *cmd_cookie,
const void *cookie,
14 ENGINE_ERROR_CODE (*response_handler)(
const void *cookie,
17 static void abort_command(
const void *cmd_cookie,
const void *cookie);
21 .accept = accept_command,
22 .execute = execute_command,
23 .abort = abort_command,
24 .cookie = &scrub_descriptor
27 GET_SERVER_API server_api;
29 static const char *get_name(
const void *cmd_cookie) {
33 static bool accept_command(
const void *cmd_cookie,
void *cookie,
34 int argc,
token_t *argv,
size_t *ndata,
36 return strcmp(argv[0].value,
"scrub") == 0;
39 static bool my_response_handler(
const void *key, uint16_t keylen,
40 const void *ext, uint8_t extlen,
41 const void *body, uint32_t bodylen,
42 uint8_t datatype, uint16_t status,
43 uint64_t cas,
const void *cookie)
45 uint16_t *rval = (uint16_t*)cookie;
50 static ENGINE_ERROR_CODE execute_command(
const void *cmd_cookie,
const void *cookie,
52 ENGINE_ERROR_CODE (*response_handler)(
const void *cookie,
57 .request.magic = (uint8_t)PROTOCOL_BINARY_REQ,
58 .request.opcode = PROTOCOL_BINARY_CMD_SCRUB
65 return response_handler(cookie, 29,
"SERVER_ERROR internal error\r\n");
68 v1->
unknown_command(server->engine, &status, &request, my_response_handler);
70 if (status == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
71 return response_handler(cookie, 4,
"OK\r\n");
72 }
else if (status == PROTOCOL_BINARY_RESPONSE_EBUSY) {
73 return response_handler(cookie, 6,
"BUSY\r\n");
75 return response_handler(cookie, 7,
"ERROR\r\n");
79 static void abort_command(
const void *cmd_cookie,
const void *cookie)
86 GET_SERVER_API get_server_api) {
87 server_api = get_server_api;