Test coder demo.

This commit is contained in:
shuxin   zheng 2023-12-26 11:26:33 +08:00
parent 2f42289ebd
commit 72feade14a
2 changed files with 24 additions and 8 deletions

View File

@ -15,7 +15,7 @@ static void b64_encode(const char *ptr)
acl_vstring_free(str); 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); ACL_VSTRING *str = acl_vstring_alloc(1);
const char *p; const char *p;
@ -29,10 +29,17 @@ static void b64_decode(const char *ptr)
DECODE(str, ptr, strlen(ptr)); DECODE(str, ptr, strlen(ptr));
p = acl_vstring_str(str); p = acl_vstring_str(str);
printf(">>>decode result:|%s|\n>>>orignal str: {%s}, len: %d\n", if (verbose) {
p, ptr, (int) ACL_VSTRING_LEN(str)); printf(">>>decode result:|%s|\n>>>orignal str: {%s}, len: %d\n",
b64_encode(p); p, ptr, (int) ACL_VSTRING_LEN(str));
printf("len: %d, %d\n", (int) ACL_VSTRING_LEN(str), (int) strlen(p)); } 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); acl_vstring_free(str);
} }
@ -70,6 +77,7 @@ static void usage(const char *prog)
printf("usage: %s -s string\r\n" printf("usage: %s -s string\r\n"
" -a action[default: encode, encode|decode]\r\n" " -a action[default: encode, encode|decode]\r\n"
" -t type [default: base64, base64|bin|crc32]\r\n" " -t type [default: base64, base64|bin|crc32]\r\n"
" -V [verbose]\r\n"
" -h help]\n", prog); " -h help]\n", prog);
} }
@ -79,7 +87,7 @@ static void usage(const char *prog)
int main(int argc, char *argv[]) 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; char *buf = NULL;
if (argc == 1) { if (argc == 1) {
@ -87,7 +95,7 @@ int main(int argc, char *argv[])
exit (1); exit (1);
} }
while ((ch = getopt(argc, argv, "s:a:t:h")) > 0) { while ((ch = getopt(argc, argv, "s:a:t:hV")) > 0) {
switch (ch) { switch (ch) {
case 's': case 's':
buf = strdup(optarg); buf = strdup(optarg);
@ -107,6 +115,9 @@ int main(int argc, char *argv[])
case 'h': case 'h':
usage(argv[0]); usage(argv[0]);
return 0; return 0;
case 'V':
verbose = 1;
break;
default: default:
usage(argv[0]); usage(argv[0]);
return 0; return 0;
@ -124,7 +135,7 @@ int main(int argc, char *argv[])
if (encode) { if (encode) {
b64_encode(buf); b64_encode(buf);
} else { } else {
b64_decode(buf); b64_decode(buf, verbose);
} }
break; break;
case BIN_TYPE: case BIN_TYPE:

View File

@ -61,6 +61,7 @@ void redis_pipeline_channel::push(redis_pipeline_message* msg)
bool redis_pipeline_channel::flush_all(void) bool redis_pipeline_channel::flush_all(void)
{ {
if (msgs_.empty()) { if (msgs_.empty()) {
logger("The messages are empty!");
return true; return true;
} }
@ -92,6 +93,7 @@ bool redis_pipeline_channel::flush_all(void)
// Return false if we have retried // Return false if we have retried
if (retried) { if (retried) {
logger_error("Retried failed!");
return false; return false;
} }
@ -253,6 +255,8 @@ bool redis_pipeline_channel::handle_messages(void)
return true; return true;
} }
logger_warn("wait results failed, try again!");
if (retried) { if (retried) {
logger_error("Retried failed"); logger_error("Retried failed");
break; break;
@ -264,6 +268,7 @@ bool redis_pipeline_channel::handle_messages(void)
logger_error("Reopen failed"); logger_error("Reopen failed");
break; break;
} }
logger("Connection opened OK, addr=%s", client_->get_addr());
} }
all_failed(); all_failed();