From 2fb84c4056c0a0040da40d94c029d90eddeca66a Mon Sep 17 00:00:00 2001 From: ubuntu14 Date: Wed, 26 Aug 2015 05:45:40 -0700 Subject: [PATCH] optimize some codes --- lib_acl/samples/Makefile.in | 18 +++++++---------- lib_acl_cpp/changes.txt | 4 ++++ lib_acl_cpp/include/acl_cpp/stdlib/string.hpp | 9 ++++++--- lib_acl_cpp/samples/Makefile.in | 4 ++-- .../samples/redis/redis_hash/redis_hash.cpp | 19 +++++++++++++++--- .../redis_hyperloglog/redis_hyperloglog.cpp | 20 ++++++++++++++++--- .../samples/redis/redis_key/redis_key.cpp | 19 ++++++++++++++++-- .../samples/redis/redis_list/redis_list.cpp | 17 +++++++++++++++- .../redis/redis_pubsub/redis_pubsub.cpp | 19 ++++++++++++++++-- .../samples/redis/redis_set/redis_set.cpp | 19 ++++++++++++++++-- .../redis/redis_string/redis_string.cpp | 19 ++++++++++++++++-- .../samples/redis/redis_zset/redis_zset.cpp | 19 ++++++++++++++++-- lib_acl_cpp/src/redis/redis_command.cpp | 3 +++ lib_acl_cpp/src/stdlib/string.cpp | 9 +++++---- lib_protocol/samples/Makefile.in | 15 +++++++------- lib_protocol/samples/Makefile_cpp.in | 14 +++++-------- 16 files changed, 174 insertions(+), 53 deletions(-) diff --git a/lib_acl/samples/Makefile.in b/lib_acl/samples/Makefile.in index daef9cfd8..1746702b5 100644 --- a/lib_acl/samples/Makefile.in +++ b/lib_acl/samples/Makefile.in @@ -20,7 +20,7 @@ CFLAGS = -c -g -W -Wall -Wcast-qual \ ########################################################### #Check system: # Linux, SunOS, Solaris, BSD variants, AIX, HP-UX -SYSLIB = -lpthread -rdynamic +SYSLIB = -lpthread CHECKSYSRES = @echo "Unknow system type!";exit 1 UNIXNAME = $(shell uname -sm) @@ -52,34 +52,30 @@ endif # For FreeBSD ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD) CFLAGS += -DFREEBSD - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif # For Darwin ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin) CFLAGS += -DMACOSX -Wno-invalid-source-encoding \ -Wno-extended-offsetof + SYSLIB += -rdynamic UNIXTYPE = MACOSX endif #Path for Linux ifeq ($(findstring Linux, $(UNIXNAME)), Linux) CFLAGS += -DLINUX2 - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif # For MINGW ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW) - SYSLIB = -lpthread-2 CFLAGS += -DLINUX2 -DMINGW + SYSLIB = -lpthread-2 -rdynamic UNIXTYPE = LINUX endif -# For Darwin -ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin) - CFLAGS += -DMACOSX -endif - #Path for SunOS ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS) ifeq ($(findstring 86, $(UNIXNAME)), 86) @@ -89,14 +85,14 @@ ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS) SYSLIB += -lsocket -lnsl -lrt endif CFLAGS += -DSUNOS5 - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif #Path for HP-UX ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX) CFLAGS += -DHP_UX -DHPUX11 PLAT_NAME=hp-ux - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif #Find system type. diff --git a/lib_acl_cpp/changes.txt b/lib_acl_cpp/changes.txt index bb4c7d102..303371147 100644 --- a/lib_acl_cpp/changes.txt +++ b/lib_acl_cpp/changes.txt @@ -1,6 +1,10 @@ 修改历史列表: ------------------------------------------------------------------------ +350) 2015.8.26 +350.1) feature: string 类在进行 base64 解码时,需要自动在尾部添加 \0 以防止使用者 +缓冲区溢出 + 349) 2015.8.24 349.1) bugfix: redis_command/redis_key/redis_hash/redis_set/redis_zset 在 遍历过程中,可能服务端会返回 cursor 为 > 0 但结果集为空的情况,需要对这种情况进行处理 diff --git a/lib_acl_cpp/include/acl_cpp/stdlib/string.hpp b/lib_acl_cpp/include/acl_cpp/stdlib/string.hpp index ef95da2ff..9b82d4b8b 100644 --- a/lib_acl_cpp/include/acl_cpp/stdlib/string.hpp +++ b/lib_acl_cpp/include/acl_cpp/stdlib/string.hpp @@ -1052,14 +1052,16 @@ class ACL_CPP_API string /** * 如果当前对象的缓冲区中的数据是经 base64 编码的,则此函数将这些 * 数据进行解码 - * @return {string&} 当前对象的引用 + * @return {string&} 当前对象的引用,如果解码出错,则内部缓冲区会被自动清空, + * 调用 string::empty() 返回 true */ string& base64_decode(void); /** * 将输入的 base64 编码的数据进行解码并存入当前对象的缓冲区中 * @param s {const char*} 经 base64 编码的源数据 - * @return {string&} 当前对象的引用 + * @return {string&} 当前对象的引用,如果解码出错,则内部缓冲区会被自动清空, + * 调用 string::empty() 返回 true */ string& base64_decode(const char* s); @@ -1067,7 +1069,8 @@ class ACL_CPP_API string * 将输入的 base64 编码的数据进行解码并存入当前对象的缓冲区中 * @param ptr {const void*} 经 base64 编码的源数据 * @param len {size_t} ptr 数据长度 - * @return {string&} 当前对象的引用 + * @return {string&} 当前对象的引用,如果解码出错,则内部缓冲区会被自动清空, + * 调用 string::empty() 返回 true */ string& base64_decode(const void* ptr, size_t len); diff --git a/lib_acl_cpp/samples/Makefile.in b/lib_acl_cpp/samples/Makefile.in index 1642d3c27..b8f01e118 100644 --- a/lib_acl_cpp/samples/Makefile.in +++ b/lib_acl_cpp/samples/Makefile.in @@ -43,8 +43,8 @@ endif ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin) CFLAGS += -DMACOSX -Wno-invalid-source-encoding \ -Wno-extended-offsetof - UNIXTYPE = MACOSX SYSLIB += -rdynamic + UNIXTYPE = MACOSX endif #Path for Linux @@ -56,7 +56,7 @@ ifeq ($(findstring Linux, $(OSNAME)), Linux) RPATH = linux64 endif CFLAGS += -DLINUX2 - SYSLIB += -rdynamic + SYSLIB += -rdynamic endif # For MINGW diff --git a/lib_acl_cpp/samples/redis/redis_hash/redis_hash.cpp b/lib_acl_cpp/samples/redis/redis_hash/redis_hash.cpp index c61e3f0e5..062453be4 100644 --- a/lib_acl_cpp/samples/redis/redis_hash/redis_hash.cpp +++ b/lib_acl_cpp/samples/redis/redis_hash/redis_hash.cpp @@ -367,6 +367,7 @@ static void usage(const char* procname) "-C connect_timeout[default: 10]\r\n" "-I rw_timeout[default: 10]\r\n" "-S [if slice request, default: no]\r\n" + "-c [cluster mode]\r\n" "-a cmd[hmset|hmget|hset|hsetnx|hget|hgetall|hincrby|hincrbyfloat|hkeys|hexists|hlen|hdel]\r\n", procname); } @@ -375,9 +376,9 @@ int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 10; acl::string addr("127.0.0.1:6379"), cmd; - bool slice_req = false; + bool slice_req = false, cluster_mode = false; - while ((ch = getopt(argc, argv, "hs:n:C:I:a:S")) > 0) + while ((ch = getopt(argc, argv, "hs:n:C:I:a:Sc")) > 0) { switch (ch) { @@ -402,15 +403,27 @@ int main(int argc, char* argv[]) case 'S': slice_req = true; break; + case 'c': + cluster_mode = true; + break; default: break; } } acl::acl_cpp_init(); + + acl::redis_client_cluster cluster(conn_timeout, rw_timeout); + cluster.set(addr.c_str(), 100); + acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); client.set_slice_request(slice_req); - acl::redis_hash redis(&client); + + acl::redis_hash redis; + if (cluster_mode) + redis.set_cluster(&cluster, 100); + else + redis.set_client(&client); bool ret; diff --git a/lib_acl_cpp/samples/redis/redis_hyperloglog/redis_hyperloglog.cpp b/lib_acl_cpp/samples/redis/redis_hyperloglog/redis_hyperloglog.cpp index 6720cf800..e21e2ab95 100644 --- a/lib_acl_cpp/samples/redis/redis_hyperloglog/redis_hyperloglog.cpp +++ b/lib_acl_cpp/samples/redis/redis_hyperloglog/redis_hyperloglog.cpp @@ -97,6 +97,7 @@ static void usage(const char* procname) "-C connect_timeout[default: 10]\r\n" "-I rw_timeout[default: 10]\r\n" "-S [if slice request, default: no]\r\n" + "-c [use cluster mode]\r\n" "-a cmd[pfadd|pfcount|pfmerge]\r\n", procname); } @@ -105,9 +106,9 @@ int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 10; acl::string addr("127.0.0.1:6379"), cmd; - bool slice_req = false; + bool slice_req = false, cluster_mode = false; - while ((ch = getopt(argc, argv, "hs:n:C:I:a:S")) > 0) + while ((ch = getopt(argc, argv, "hs:n:C:I:a:Sc")) > 0) { switch (ch) { @@ -132,15 +133,28 @@ int main(int argc, char* argv[]) case 'S': slice_req = true; break; + case 'c': + cluster_mode = true; + break; default: break; } } acl::acl_cpp_init(); + + acl::redis_client_cluster cluster(conn_timeout, rw_timeout); + cluster.set(addr.c_str(), 100); + acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); client.set_slice_request(slice_req); - acl::redis_hyperloglog redis(&client); + + acl::redis_hyperloglog redis; + + if (cluster_mode) + redis.set_cluster(&cluster, 100); + else + redis.set_client(&client); bool ret; diff --git a/lib_acl_cpp/samples/redis/redis_key/redis_key.cpp b/lib_acl_cpp/samples/redis/redis_key/redis_key.cpp index 8da08e4a6..cec1846ab 100644 --- a/lib_acl_cpp/samples/redis/redis_key/redis_key.cpp +++ b/lib_acl_cpp/samples/redis/redis_key/redis_key.cpp @@ -114,6 +114,7 @@ static void usage(const char* procname) "-n count\r\n" "-C connect_timeout[default: 10]\r\n" "-T rw_timeout[default: 10]\r\n" + "-c [use cluster mode]\r\n" "-a cmd[del|expire|ttl|exists|type|all]\r\n", procname); } @@ -122,8 +123,9 @@ int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 10; acl::string addr("127.0.0.1:6379"), cmd; + bool cluster_mode = false; - while ((ch = getopt(argc, argv, "hs:n:C:T:a:")) > 0) + while ((ch = getopt(argc, argv, "hs:n:C:T:a:c")) > 0) { switch (ch) { @@ -145,14 +147,27 @@ int main(int argc, char* argv[]) case 'a': cmd = optarg; break; + case 'c': + cluster_mode = true; + break; default: break; } } acl::acl_cpp_init(); + + acl::redis_client_cluster cluster(conn_timeout, rw_timeout); + cluster.set(addr.c_str(), 100); + acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); - acl::redis_key redis(&client); + + acl::redis_key redis; + + if (cluster_mode) + redis.set_cluster(&cluster, 100); + else + redis.set_client(&client); bool ret; diff --git a/lib_acl_cpp/samples/redis/redis_list/redis_list.cpp b/lib_acl_cpp/samples/redis/redis_list/redis_list.cpp index 2430a35ab..2aa78a1e6 100644 --- a/lib_acl_cpp/samples/redis/redis_list/redis_list.cpp +++ b/lib_acl_cpp/samples/redis/redis_list/redis_list.cpp @@ -701,6 +701,7 @@ static void usage(const char* procname) "-C connect_timeout[default: 10]\r\n" "-I rw_timeout[default: 10]\r\n" "-S [if slice request, default: no]\r\n" + "-c [use cluster mode]\r\n" "-a cmd[lpush|rpush|lpushx|rpushx|lrange|rpop|lpop|blpop|brpop|rpoplpush|brpoplpush|lrem|ltrim|llen|lindex|lset|linsert_before|linsert_after]\r\n", procname); } @@ -709,8 +710,9 @@ int main(int argc, char* argv[]) { int ch, n = 50, conn_timeout = 10, rw_timeout = 10; acl::string addr("127.0.0.1:6379"), cmd("all"); + bool cluster_mode = false; - while ((ch = getopt(argc, argv, "hs:n:C:T:a:")) > 0) + while ((ch = getopt(argc, argv, "hs:n:C:T:a:c")) > 0) { switch (ch) { @@ -732,15 +734,28 @@ int main(int argc, char* argv[]) case 'a': cmd = optarg; break; + case 'c': + cluster_mode = true; + break; default: break; } } acl::acl_cpp_init(); + + acl::redis_client_cluster cluster(conn_timeout, rw_timeout); + cluster.set(addr.c_str(), 100); + acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); + acl::redis_list redis(&client); + if (cluster_mode) + redis.set_cluster(&cluster, 100); + else + redis.set_client(&client); + bool ret; if (cmd == "lpush") diff --git a/lib_acl_cpp/samples/redis/redis_pubsub/redis_pubsub.cpp b/lib_acl_cpp/samples/redis/redis_pubsub/redis_pubsub.cpp index ed1685aa0..ac06a7e93 100644 --- a/lib_acl_cpp/samples/redis/redis_pubsub/redis_pubsub.cpp +++ b/lib_acl_cpp/samples/redis/redis_pubsub/redis_pubsub.cpp @@ -119,6 +119,7 @@ static void usage(const char* procname) "-n count\r\n" "-C connect_timeout[default: 10]\r\n" "-I rw_timeout[default: 0]\r\n" + "-c [use cluster mode]\r\n" "-a cmd[subscribe|publish]\r\n", procname); } @@ -127,8 +128,9 @@ int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 0; acl::string addr("127.0.0.1:6379"), cmd; + bool cluster_mode = false; - while ((ch = getopt(argc, argv, "hs:n:C:I:a:")) > 0) + while ((ch = getopt(argc, argv, "hs:n:C:I:a:c")) > 0) { switch (ch) { @@ -150,6 +152,9 @@ int main(int argc, char* argv[]) case 'a': cmd = optarg; break; + case 'c': + cluster_mode = true; + break; default: break; } @@ -157,8 +162,18 @@ int main(int argc, char* argv[]) acl::acl_cpp_init(); acl::log::stdout_open(true); + + acl::redis_client_cluster cluster(conn_timeout, rw_timeout); + cluster.set(addr.c_str(), 100); + acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); - acl::redis_pubsub redis(&client); + + acl::redis_pubsub redis; + + if (cluster_mode) + redis.set_cluster(&cluster, 100); + else + redis.set_client(&client); bool ret; diff --git a/lib_acl_cpp/samples/redis/redis_set/redis_set.cpp b/lib_acl_cpp/samples/redis/redis_set/redis_set.cpp index 3a8f76058..d3e6d2a41 100644 --- a/lib_acl_cpp/samples/redis/redis_set/redis_set.cpp +++ b/lib_acl_cpp/samples/redis/redis_set/redis_set.cpp @@ -401,6 +401,7 @@ static void usage(const char* procname) "-n count\r\n" "-C connect_timeout[default: 10]\r\n" "-T rw_timeout[default: 10]\r\n" + "-c [use cluster mode]\r\n" "-a cmd[sadd|scard|sdiffstore|sismember|smembers|smove|spop|srandmember|sunion|sunionstore|sscan|srem\r\n", procname); } @@ -409,8 +410,9 @@ int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 10; acl::string addr("127.0.0.1:6379"), cmd; + bool cluster_mode = false; - while ((ch = getopt(argc, argv, "hs:n:C:T:a:")) > 0) + while ((ch = getopt(argc, argv, "hs:n:C:T:a:c")) > 0) { switch (ch) { @@ -432,14 +434,27 @@ int main(int argc, char* argv[]) case 'a': cmd = optarg; break; + case 'c': + cluster_mode = true; + break; default: break; } } acl::acl_cpp_init(); + + acl::redis_client_cluster cluster(conn_timeout, rw_timeout); + cluster.set(addr.c_str(), 100); + acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); - acl::redis_set redis(&client); + + acl::redis_set redis; + + if (cluster_mode) + redis.set_cluster(&cluster, 100); + else + redis.set_client(&client); bool ret; diff --git a/lib_acl_cpp/samples/redis/redis_string/redis_string.cpp b/lib_acl_cpp/samples/redis/redis_string/redis_string.cpp index 420d95118..59eb16173 100644 --- a/lib_acl_cpp/samples/redis/redis_string/redis_string.cpp +++ b/lib_acl_cpp/samples/redis/redis_string/redis_string.cpp @@ -652,6 +652,7 @@ static void usage(const char* procname) "-C connect_timeout[default: 10]\r\n" "-I rw_timeout[default: 10]\r\n" "-t object timeout[default: 10]\r\n" + "-c [use cluster mode]\r\n" "-a cmd[set|setex|setnx|append|get|getset|strlen|mset|mget|msetnx|setrange|getrange|setbit|getbit|bitcount|bitop_and|bitop_or|bitop_xor|incr|incrby|incrbyfloat|decr|decrby]\r\n", procname); } @@ -660,8 +661,9 @@ int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 10, ttl = 10; acl::string addr("127.0.0.1:6379"), cmd; + bool cluster_mode = false; - while ((ch = getopt(argc, argv, "hs:n:C:I:a:t:")) > 0) + while ((ch = getopt(argc, argv, "hs:n:C:I:a:t:c")) > 0) { switch (ch) { @@ -686,6 +688,9 @@ int main(int argc, char* argv[]) case 't': ttl = atoi(optarg); break; + case 'c': + cluster_mode = true; + break; default: break; } @@ -693,8 +698,18 @@ int main(int argc, char* argv[]) acl::acl_cpp_init(); acl::log::stdout_open(true); + + acl::redis_client_cluster cluster(conn_timeout, rw_timeout); + cluster.set(addr.c_str(), 100); + acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); - acl::redis_string redis(&client); + + acl::redis_string redis; + + if (cluster_mode) + redis.set_cluster(&cluster, 100); + else + redis.set_client(&client); bool ret; diff --git a/lib_acl_cpp/samples/redis/redis_zset/redis_zset.cpp b/lib_acl_cpp/samples/redis/redis_zset/redis_zset.cpp index c91b47a15..2968df8ed 100644 --- a/lib_acl_cpp/samples/redis/redis_zset/redis_zset.cpp +++ b/lib_acl_cpp/samples/redis/redis_zset/redis_zset.cpp @@ -543,6 +543,7 @@ static void usage(const char* procname) "-n count\r\n" "-C connect_timeout[default: 10]\r\n" "-T rw_timeout[default: 10]\r\n" + "-c [use cluster mode]\r\n" "-a cmd[zadd|zcard|zcount|zincrby|zrange|zrangebyscore|zrank|zrem|zscore|zunionstore|zinterstore|zscan|zrangebylex|zlexcount|zremrangebylex]\r\n", procname); } @@ -551,8 +552,9 @@ int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 10; acl::string addr("127.0.0.1:6379"), cmd; + bool cluster_mode = false; - while ((ch = getopt(argc, argv, "hs:n:C:T:a:")) > 0) + while ((ch = getopt(argc, argv, "hs:n:C:T:a:c")) > 0) { switch (ch) { @@ -574,14 +576,27 @@ int main(int argc, char* argv[]) case 'a': cmd = optarg; break; + case 'c': + cluster_mode = true; + break; default: break; } } acl::acl_cpp_init(); + + acl::redis_client_cluster cluster(conn_timeout, rw_timeout); + cluster.set(addr.c_str(), 100); + acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); - acl::redis_zset redis(&client); + + acl::redis_zset redis; + + if (cluster_mode) + redis.set_cluster(&cluster, 100); + else + redis.set_client(&client); bool ret; diff --git a/lib_acl_cpp/src/redis/redis_command.cpp b/lib_acl_cpp/src/redis/redis_command.cpp index 44ed0fd5c..88ae95eba 100644 --- a/lib_acl_cpp/src/redis/redis_command.cpp +++ b/lib_acl_cpp/src/redis/redis_command.cpp @@ -605,6 +605,9 @@ const redis_result* redis_command::run(redis_client_cluster* cluster, conn->get_pool()->put(conn, true); logger_error("server error: %s", ptr); + if (!slice_req_) + logger_error("request: %s", + request_buf_->c_str()); return result_; } } diff --git a/lib_acl_cpp/src/stdlib/string.cpp b/lib_acl_cpp/src/stdlib/string.cpp index 3e84380bd..de28e468c 100644 --- a/lib_acl_cpp/src/stdlib/string.cpp +++ b/lib_acl_cpp/src/stdlib/string.cpp @@ -1351,16 +1351,16 @@ string& string::base64_decode(void) RSET(s); FREE(vbf_); vbf_ = s; + TERM(vbf_); return *this; } string& string::base64_decode(const char* s) { - if (acl_vstring_base64_decode(vbf_, - s, (int) strlen(s)) == NULL) - { + if (acl_vstring_base64_decode(vbf_, s, (int) strlen(s)) == NULL) RSET(vbf_); - } + + TERM(vbf_); return *this; } @@ -1371,6 +1371,7 @@ string& string::base64_decode(const void* ptr, size_t len) { RSET(vbf_); } + TERM(vbf_); return *this; } diff --git a/lib_protocol/samples/Makefile.in b/lib_protocol/samples/Makefile.in index 3e88d0cfa..431cd7dc8 100644 --- a/lib_protocol/samples/Makefile.in +++ b/lib_protocol/samples/Makefile.in @@ -21,7 +21,7 @@ CFLAGS = -c -g -W \ ########################################################### #Check system: # Linux, SunOS, Solaris, BSD variants, AIX, HP-UX -SYSLIB = -lpthread -rdynamic +SYSLIB = -lpthread CHECKSYSRES = @echo "Unknow system type!";exit 1 UNIXNAME = $(shell uname -sm) @@ -47,25 +47,26 @@ endif # For FreeBSD ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD) CFLAGS += -DFREEBSD - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif # For Darwin ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin) CFLAGS += -DMACOSX -Wno-invalid-source-encoding \ -Wno-extended-offsetof + SYSLIB += -rdynamic UNIXTYPE = MACOSX endif #Path for Linux ifeq ($(findstring Linux, $(UNIXNAME)), Linux) CFLAGS += -DLINUX2 - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif # For MINGW ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW) - SYSLIB = -lpthread-2 + SYSLIB = -lpthread-2 -rdynamic CFLAGS += -DLINUX2 -DMINGW UNIXTYPE = LINUX endif @@ -79,14 +80,14 @@ ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS) SYSLIB += -lsocket -lnsl -lrt endif CFLAGS += -DSUNOS5 - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif #Path for HP-UX ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX) - CFLAGS += -DHP_UX -DHPUX11 PLAT_NAME=hp-ux - SYSLIB += -lcrypt + CFLAGS += -DHP_UX -DHPUX11 + SYSLIB += -lcrypt -rdynamic endif #Find system type. diff --git a/lib_protocol/samples/Makefile_cpp.in b/lib_protocol/samples/Makefile_cpp.in index e9e6314f0..4e8928953 100644 --- a/lib_protocol/samples/Makefile_cpp.in +++ b/lib_protocol/samples/Makefile_cpp.in @@ -43,27 +43,28 @@ endif # For FreeBSD ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD) CFLAGS += -DFREEBSD -pedantic - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif # For Darwin ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin) CFLAGS += -DMACOSX -Wno-invalid-source-encoding \ -Wno-extended-offsetof + SYSLIB += -rdynamic UNIXTYPE = MACOSX endif #Path for Linux ifeq ($(findstring Linux, $(UNIXNAME)), Linux) CFLAGS += -DLINUX2 -pedantic - SYSLIB += -lcrypt + SYSLIB += -lcrypt -rdynamic endif # For MINGW ifeq ($(findstring MINGW, $(UNIXNAME)), MINGW) SYSLIB = -lpthread-2 CFLAGS += -DLINUX2 -DMINGW - UNIXTYPE = LINUX + UNIXTYPE = LINUX -rdynamic endif #Path for SunOS @@ -82,12 +83,7 @@ endif ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX) CFLAGS += -DHP_UX -DHPUX11 PLAT_NAME=hp-ux - SYSLIB += -lcrypt -endif - -# For Darwin -ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin) - CFLAGS += -DMACOSX + SYSLIB += -lcrypt -rdynamic endif #Find system type.