From 72feade14a1286376dc6ed961f250ac9f185a33c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?shuxin=20=E3=80=80=E3=80=80zheng?= Date: Tue, 26 Dec 2023 11:26:33 +0800 Subject: [PATCH] Test coder demo. --- lib_acl/samples/coder/main.c | 27 +++++++++++++------ .../src/redis/redis_client_pipeline.cpp | 5 ++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib_acl/samples/coder/main.c b/lib_acl/samples/coder/main.c index b7740f29f..fd5dfc3c5 100644 --- a/lib_acl/samples/coder/main.c +++ b/lib_acl/samples/coder/main.c @@ -15,7 +15,7 @@ static void b64_encode(const char *ptr) acl_vstring_free(str); } -static void b64_decode(const char *ptr) +static void b64_decode(const char *ptr, int verbose) { ACL_VSTRING *str = acl_vstring_alloc(1); const char *p; @@ -29,10 +29,17 @@ static void b64_decode(const char *ptr) DECODE(str, ptr, strlen(ptr)); p = acl_vstring_str(str); - printf(">>>decode result:|%s|\n>>>orignal str: {%s}, len: %d\n", - p, ptr, (int) ACL_VSTRING_LEN(str)); - b64_encode(p); - printf("len: %d, %d\n", (int) ACL_VSTRING_LEN(str), (int) strlen(p)); + if (verbose) { + printf(">>>decode result:|%s|\n>>>orignal str: {%s}, len: %d\n", + p, ptr, (int) ACL_VSTRING_LEN(str)); + } else { + printf("%s\n", p); + } + + if (verbose) { + b64_encode(p); + printf("len: %d, %d\n", (int) ACL_VSTRING_LEN(str), (int) strlen(p)); + } acl_vstring_free(str); } @@ -70,6 +77,7 @@ static void usage(const char *prog) printf("usage: %s -s string\r\n" " -a action[default: encode, encode|decode]\r\n" " -t type [default: base64, base64|bin|crc32]\r\n" + " -V [verbose]\r\n" " -h help]\n", prog); } @@ -79,7 +87,7 @@ static void usage(const char *prog) int main(int argc, char *argv[]) { - int ch, encode = 1, type = BASE64_TYPE; + int ch, encode = 1, type = BASE64_TYPE, verbose = 0; char *buf = NULL; if (argc == 1) { @@ -87,7 +95,7 @@ int main(int argc, char *argv[]) exit (1); } - while ((ch = getopt(argc, argv, "s:a:t:h")) > 0) { + while ((ch = getopt(argc, argv, "s:a:t:hV")) > 0) { switch (ch) { case 's': buf = strdup(optarg); @@ -107,6 +115,9 @@ int main(int argc, char *argv[]) case 'h': usage(argv[0]); return 0; + case 'V': + verbose = 1; + break; default: usage(argv[0]); return 0; @@ -124,7 +135,7 @@ int main(int argc, char *argv[]) if (encode) { b64_encode(buf); } else { - b64_decode(buf); + b64_decode(buf, verbose); } break; case BIN_TYPE: diff --git a/lib_acl_cpp/src/redis/redis_client_pipeline.cpp b/lib_acl_cpp/src/redis/redis_client_pipeline.cpp index d6abe1b29..dd937f43e 100644 --- a/lib_acl_cpp/src/redis/redis_client_pipeline.cpp +++ b/lib_acl_cpp/src/redis/redis_client_pipeline.cpp @@ -61,6 +61,7 @@ void redis_pipeline_channel::push(redis_pipeline_message* msg) bool redis_pipeline_channel::flush_all(void) { if (msgs_.empty()) { + logger("The messages are empty!"); return true; } @@ -92,6 +93,7 @@ bool redis_pipeline_channel::flush_all(void) // Return false if we have retried if (retried) { + logger_error("Retried failed!"); return false; } @@ -253,6 +255,8 @@ bool redis_pipeline_channel::handle_messages(void) return true; } + logger_warn("wait results failed, try again!"); + if (retried) { logger_error("Retried failed"); break; @@ -264,6 +268,7 @@ bool redis_pipeline_channel::handle_messages(void) logger_error("Reopen failed"); break; } + logger("Connection opened OK, addr=%s", client_->get_addr()); } all_failed();