Commit 2d0c8c3b authored by zhujiashun's avatar zhujiashun

redis_server_protocol: refine code

parent a79093b4
......@@ -104,7 +104,7 @@ private:
int main(int argc, char* argv[]) {
google::ParseCommandLineFlags(&argc, &argv, true);
RedisServiceImpl* rsimpl = new RedisServiceImpl;
RedisServiceImpl* rsimpl = new RedisServiceImpl;
rsimpl->AddCommandHandler("get", new GetCommandHandler(rsimpl));
rsimpl->AddCommandHandler("set", new SetCommandHandler(rsimpl));
......
......@@ -18,7 +18,6 @@
// Authors: Ge,Jun (gejun@baidu.com)
// Jiashun Zhu(zhujiashun2010@gmail.com)
#include <queue>
#include <google/protobuf/descriptor.h> // MethodDescriptor
#include <google/protobuf/message.h> // Message
#include <gflags/gflags.h>
......@@ -45,7 +44,7 @@ namespace policy {
DEFINE_bool(redis_verbose, false,
"[DEBUG] Print EVERY redis request/response");
DEFINE_int32(redis_batch_flush_max_size, 2048, "beyond which the server response"
DEFINE_int32(redis_batch_flush_max_size, 4096, "beyond which the server response"
" are forced to write to socket");
struct InputResponse : public InputMessageBase {
......@@ -165,9 +164,14 @@ int Consume(void* ctx, bthread::TaskIterator<RedisTask*>& iter) {
has_err = true;
continue;
}
if ((int)sendbuf.size() >= FLAGS_redis_batch_flush_max_size) {
LOG_IF(WARNING, s->Write(&sendbuf, &wopt) != 0)
<< "Fail to send redis reply";
}
}
if (!has_err) {
LOG_IF(WARNING, s->Write(&sendbuf, &wopt) != 0) << "Fail to send redis reply";
if (!has_err && !sendbuf.empty()) {
LOG_IF(WARNING, s->Write(&sendbuf, &wopt) != 0)
<< "Fail to send redis reply";
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment