Skip to content

Commit 1070c0a

Browse files
committed
Cleanup BinprotEWBCommand
Don't store the values in separate variables before encoding them as part of encode and add members to get/set the various fields Change-Id: I618d733cf97ad8c1d093eeea1729577d7348109d Reviewed-on: http://review.couchbase.org/c/kv_engine/+/138034 Tested-by: Build Bot <[email protected]> Reviewed-by: Richard de Mellow <[email protected]>
1 parent c1cc31f commit 1070c0a

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

protocol/connection/client_mcbp_commands.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,17 +1877,13 @@ BinprotEWBCommand::BinprotEWBCommand(EWBEngineMode mode,
18771877
ENGINE_ERROR_CODE err_code,
18781878
uint32_t value,
18791879
const std::string& key)
1880-
: BinprotGenericCommand(cb::mcbp::ClientOpcode::EwouldblockCtl, key),
1881-
mode(mode),
1882-
err_code(err_code),
1883-
value(value) {
1884-
}
1885-
1886-
void BinprotEWBCommand::encode(std::vector<uint8_t>& buf) const {
1887-
cb::mcbp::request::EWB_Payload extras;
1880+
: BinprotGenericCommand(cb::mcbp::ClientOpcode::EwouldblockCtl, key) {
18881881
extras.setMode(uint32_t(mode));
18891882
extras.setValue(uint32_t(value));
18901883
extras.setInjectError(uint32_t(err_code));
1884+
}
1885+
1886+
void BinprotEWBCommand::encode(std::vector<uint8_t>& buf) const {
18911887
writeHeader(buf, 0, sizeof(extras));
18921888
auto extraBuf = extras.getBuffer();
18931889
buf.insert(buf.end(), extraBuf.begin(), extraBuf.end());

protocol/connection/client_mcbp_commands.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,10 +1111,27 @@ class BinprotEWBCommand : public BinprotGenericCommand {
11111111

11121112
void encode(std::vector<uint8_t>& buf) const override;
11131113

1114+
uint32_t getMode() const {
1115+
return extras.getMode();
1116+
}
1117+
void setMode(uint32_t m) {
1118+
extras.setMode(m);
1119+
}
1120+
uint32_t getValue() const {
1121+
return extras.getValue();
1122+
}
1123+
void setValue(uint32_t v) {
1124+
extras.setValue(v);
1125+
}
1126+
uint32_t getInjectError() const {
1127+
return extras.getInjectError();
1128+
}
1129+
void setInjectError(uint32_t ie) {
1130+
extras.setInjectError(ie);
1131+
}
1132+
11141133
protected:
1115-
EWBEngineMode mode;
1116-
ENGINE_ERROR_CODE err_code;
1117-
uint32_t value;
1134+
cb::mcbp::request::EWB_Payload extras;
11181135
};
11191136

11201137
class BinprotCompactDbCommand : public BinprotGenericCommand {

0 commit comments

Comments
 (0)