Git Product home page Git Product logo

acl-dev / acl Goto Github PK

View Code? Open in Web Editor NEW
2.8K 216.0 934.0 120.34 MB

C/C++ server and network library, including coroutine,redis client,http/https/websocket,mqtt, mysql/postgresql/sqlite client with C/C++ for Linux, Android, iOS, MacOS, Windows, etc..

Home Page: https://acl-dev.cn

License: GNU Lesser General Public License v3.0

Makefile 1.41% C 55.89% HTML 12.97% CSS 0.04% Java 0.12% C++ 26.95% Shell 0.33% Inno Setup 0.03% Objective-C 0.04% JavaScript 0.72% CMake 0.18% Roff 0.01% Objective-C++ 0.01% Lua 0.03% Assembly 1.19% Python 0.02% Starlark 0.05% TypeScript 0.01% Batchfile 0.01%
coroutine database fiber http-client http-server mqtt-client mqtt-protocol network redis-client smtp memcached-clients redis http https websocket cplusplus

acl's Introduction

中文简体

Acl -- One Advanced C/C++ Library for Unix/Windows

0. About Acl project

The Acl (Advanced C/C++ Library) project a is powerful multi-platform network communication library and service framework, suppoting LINUX, WIN32, Solaris, FreeBSD, MacOS, AndroidOS, iOS. Many applications written by Acl run on these devices with Linux, Windows, iPhone and Android and serve billions of users. There are some important modules in Acl project, including network communcation, server framework, application protocols, multiple coders, etc. The common protocols such as HTTP/SMTP/ICMP//MQTT/Redis/Memcached/Beanstalk/Handler Socket are implemented in Acl, and the codec library such as XML/JSON/MIME/BASE64/UUCODE/QPCODE/RFC2047/RFC1035, etc., are also included in Acl. Acl also provides unified abstract interface for popular databases such as Mysql, Postgresql, Sqlite. Using Acl library users can write database application more easily, quickly and safely.

Architecture diagram: Overall architecture diagram



1. The six most important modules

As a C/C++ foundation library, Acl provides many useful functions for users to develop applications, including six important modules: Network, Coroutine, HTTP, Redis client, MQTT, and Server framework.

1.1. Basic network module

  • Stream processing module This module is the most basic streaming communication module for the entire acl network communication. It not only supports network streaming, but also supports file streaming. It mainly supports:

    • Read data by line, compatible with \r\n under win32, and compatible with the end of \n under UNIX
    • Read data by line but require automatic removal of the trailing \n or \r\n
    • Read data as a string separator
    • Read the specified length of data
    • Try to read a row of data or try to read the specified length of data
    • Detect network IO status
    • Write a row of data
    • Write data by formatter, similar to fprintf
    • File stream location operation, similar to fseek
    • Write a set of data at once, similar to writev under unix
    • Truncate the file, similar to ftrunk
    • Get the file size
    • Get the current file stream pointer location, similar to ftell
    • Get the file size
    • Obtain the local address and remote address of the network stream
  • Network operation module

    • This module mainly supports network server monitoring (supports TCP/UDP/UNIX domain socket), network client connection (supports TCP/UNIX domain socket), DNS domain name query and result cache (supports calling system gethostbyname/getaddrinfo function and direct Send DNS protocol two ways), socket (socket) operation and take the local network card and other functions.
  • Non-blocking network flow

    • Support non-blocking mode connection, read (by row read, specified length read), write (write line, write specified length, write a set of data) and other operations.
  • Common network application protocol library

    • It mainly supports common network application protocols, such as: HTTP, SMTP, ICMP, in which HTTP and ICMP modules implement blocking and non-blocking communication methods. In addition, the HTTP protocol supports server and client in C++ version of lib_acl_cpp. Two communication methods, when used as a server, support the interface usage similar to JAVA HttpServlet. When used as a client mode, it supports connection pool and cluster management. The module supports both cookie, session, and HTTP MIME file upload. Rich functions such as block transfer, automatic character set conversion, automatic decompression, and breakpoint resume.
  • Common network communication library

    • Support memcached, beanstalk, handler socket client communication library, the communication library supports connection pool mode.

1.2. Coroutine

The coroutine module in Acl can be used on multiple platforms, and there are many engineering practices in some important projects.

  • Run on Linux, MacOS, Windows, iOS and Android
  • Support x86, Arm architecture
  • Support select/poll/epoll/kqueue/iocp/win32 GUI message
  • The DNS protocol has been implemented in acl coroutine, so DNS API can also be used in coroutine model
  • Hook system IO API on Unix and Windows
    • Read API: read/readv/recv/recvfrom/recvmsg
    • Write API: write/writev/send/sendto/sendmsg/sendfile64
    • Socket API: socket/listen/accept/connect/setsockopt
    • event API: select/poll/epoll_create/epoll_ctl/epoll_wait
    • DNS API: gethostbyname/gethostbyname_r/getaddrinfo/freeaddrinfo
  • Support shared stack mode to minimize memory usage
  • Synchronization primitive
    • Coroutine mutex, semphore can be used between coroutines
    • Coroutine event can be used between coroutines and threads
  • For more information, see Using Acl fiber

1.3. HTTP module

Supports HTTP/1.1, can be used in client and server sides.

  • HttpServlet interface like Java(server side)
  • Connection pool mode(client side)
  • Chunked block transfer
  • Gzip compression/decompression
  • SSL encrypted
  • Breakpoints transmission
  • Setting/acquisition of cookies
  • Session managment(server side)
  • Websocket transmission
  • HTTP MIME format
  • Sync/Async mode
  • ...

1.4. Redis client

The redis client module in Acl is powerful, high-performance and easy to use.

  • Support Bitmap/String/Hash/List/Set/Sorted Set/PubSub/HyperLogLog/Geo/Script/Stream/Server/Cluster/etc.
  • Provides stl-like C++ interface for each redis command
  • Automaticaly cache and adapt the changing of hash slots of the redis cluster on the client
  • Communication in single, cluster or pipeline mode
  • Connection pool be used in signle or cluster mode
  • High performance in cluster or pipline mode
  • Same interface for single, cluster and pipeline modes
  • Retry automatically for the reason of network error
  • Can be used in the shared stack coroutine mode
  • For more information, see Using Acl redis client

1.5. MQTT module

The MQTT 3.1.1 version has been implemented in Acl, which has a stream parser, so can be used indepedentily of any IO mode.

  • Support MQTT 3.1.1 protocol: CONNECT/CONNACK/PUBLISH/PUBACK/PUBREC/PUBREL/PUBCOMP/SUBSCRIBE/SUBACK/UNSUBSCRIBE/UNSUBACK/PINGREQ/PINGRESP/DISCONNECT
  • One class per command
  • Stream parser can be used for any IO mode
  • Data parsing separats from network communicationo
  • Can be used on client and server sides
  • For more information, see Using Acl MQTT

1.6. Server framework

The most important module in Acl is the server framework, which helps users quickly write back-end services, such as web services. Tools in app/wizard can help users generate one appropriate service code within several seconds. The server framework of Acl includes two parts, one is the services manager, the other is the service written by Acl service template. The services manager named acl_master in Acl comes from the famous MTA Postfix, whose name is master, and acl_master has many extensions to master in order to be as one general services manager. There are six service templates in Acl that can be used to write application services, as below:

  • Process service: One connection one process, the advantage is that the programming is simple, safe and stable, and the disadvantage is that the concurrency is too low;
  • Threads service: Each process handles all client connections through a set of threads in the thread pool. The IO event trigger mode is used that a connection is bound to a thread only if it has readable data, and the thread will be released after processing the data. The service model's advantage is that it can handle a large number of client connections in one process with a small number of threads. Compare with the aio model, the programming is relatively simple;
  • Aio service: Similar to nginx/squid/ircd, one thread can handle a large number of client connections in a non-blocking IO manner. The advantages of this model are high processing efficiency and low resource consumption, while the disadvantages are more complex programming;
  • Coroutine service: Although the non-blocking service model can obtain large concurrent processing capability, the programming complexity is high. The coroutine model combines the features of large concurrent processing and low programming complexity, enabling programmers to easily implement sequential IO programming;
  • UDP service: The model is mainly a service model supporting UDP communication process;
  • Trigger service: The model instance is mainly used to process the background service process of some scheduled tasks (similar to the system's crontab).

2. The other important modules

2.1. MIME module

MIME(Multipurpose Internet Mail Extensions) format is widely used in email application. MIME format is too important that it can be used not only for email applications, but also for Web applications. MIME RFC such as RFC2045/RFC2047/RFC822 has been implemented in Acl. Acl has a MIME data stream parser that is indepedent of the IO model, so it can be used by synchronous or asynchronous IO programs.

2.2. Codec module

Thare are some common codecs in Acl, such as Json, Xml, Base64, Url, etc., which are all stream parser and indepedent of IO communication. Json is very popular, so Acl also provides serialization/deserialization tools which can be used to transfer between Json data and C struct objects, which greatly improves the programming efficiency.

2.3. Database module

The unified database interface in Acl is designed to easily and safely operate thease well-known open source databases such as Mysql, Postgresql and SQLite. The SQL codec is designed to escape the charactors to avoid the DB SQL attacks. When users use Acl to write database applications, Acl will dynamically load the dynamic libraries of Mysql, Postgresql or SQLite. The advantage of dynamic loading is that users who don't need the database functionality don't care about it at all.

2.4. Connection pool manager

There's a genernal connection pool manager in Acl, which is used widely by the other important modules, including redis, database, and http modules, etc.

2.5. The other client libraries

In addition to redis client, Acl also implements some other important client libraries, such as memcached client, handler-socket, beanstalk, disque and so on.

2.6. DNS module

Acl not only wraps the system DNS API, such as getaddrinfo and gethostbyname, but also implements the DNS protocol specified in RFC1035. Users can use the DNS module in Acl to implement their own DNS client or server.

3. Platform support and compilation

3.1. Compiling Acl on different platforms

Acl project currently supports Linux, Windows, MacOS, FreeBSD, Solaris, Android, and iOS.

  • Linux/UNIX: The compiler is gcc/clang, enter acl/ directory and run make, then libacl_all.a and libacl_all.so will be generated in acl/ directory, libacl_all.a is consist of three libraries including lib_acl.a, lib_protocol.a and libacl_cpp.a; You can also use cmake to build and install Acl libs by running cmake-build.sh script in Acl directory; And xmake can also compiling Acl when you run xmake in Acl directory.
  • Windows: Can be compiled with VS2003/VS2008/VS2010/VS2012/VS2013/VS2015/VS2019. (If you need to compile with VS6/VS2005, you can refer to the compilation conditions of VS2003);
  • MacOS/iOS: Compiled with xcode;
  • Android: Open Adnroid's project in acl/android/acl_c++_shared/ with Android Studio;
  • Support for cross platform compilation with cmake.

3.2. Precautions when compiling on Windows

There are a few things to keep in mind when using dynamic libraries in a WIN32 environment:

  • When using the dynamic library of lib_acl, it needs to be predefined in the user's project: ACL_DLL;
  • When using the HTTP library or ICMP library in the lib_protocol dynamic library, you need to predefine HTTP_DLL or ICMP_DLL in the project;
  • When using the dynamic library of lib_acl_cpp, you need to predefine ACL_CPP_DLL in the project. If you use the VC2003 compiler environment, you need to predefine VC2003.
  • When using the dynamic library of lib_dict, you need to predefine DICT_DLL in the project;
  • When using a dynamic library of lib_tls, you need to predefine TLS_DLL in your project.
  • Detailed compilation process, see: Compilation and use of acl library

4. Quick start

4.1. The first demo with Acl

#include <iostream>
#include "acl_cpp/lib_acl.hpp"

int main(void) {
  acl::string buf = "hello world!\r\n";
  std::cout << buf.c_str() << std::endl;
  return 0;
}

4.2. Simple TCP server

#include <thread>
#include "acl_cpp/lib_acl.hpp"

void run(void) {
  const char* addr = "127.0.0.1:8088";
  acl::server_socket server;
  if (!server.open(addr)) {  // Bind and listen the local address.
    return;
  }

  while (true) {
    acl::socket_stream* conn = server.accept(); // Wait for connection.
    if (conn == NULL) {
      break;
    }
    std::thread thread([=] {  // Start one thread to handle the connection.
      char buf[256];
      int ret = conn->read(buf, sizeof(buf), false);  // Read data.
      if (ret > 0) {
        conn->write(buf, ret);  // Write the received data.
      }
      delete conn;
    });
    thread.detach();
  }
}

4.3. Simple TCP client

#include "acl_cpp/lib_acl.hpp"

void run(void) {
  const char* addr = "127.0.0.1:8088";
  int conn_timeout = 5, rw_timeout = 10;
  acl::socket_stream conn;
  if (!conn.open(addr, conn_timeout, rw_timeout)) { // Connecting the server.
    return;
  }
  const char data[] = "Hello world!\r\n";
  if (conn.write(data, sizeof(data) - 1) == -1) {  // Send data to server.
    return;
  }
  char buf[256];
  int ret = conn.read(buf, sizeof(buf) - 1, false);
  if (ret > 0) {  // Read from server.
    buf[ret] = 0;
    std::cout << buf << std::endl;
  }
}

4.4. Coroutine TCP server

#include "acl_cpp/lib_acl.hpp"
#include "fiber/go_fiber.hpp"

void run(void) {
  const char* addr = "127.0.0.1:8088";
  acl::server_socket server;
  if (!server.open(addr)) {
    return;
  }

  go[&] {  // Create one server coroutine to wait for connection.
    while (true) {
      acl::socket_stream* conn = server.accept();
      if (conn) {
        go[=] {  // Create one client coroutine to handle the connection.
          char buf[256];
          int ret = conn->read(buf, sizeof(buf), false);
          if (ret > 0) {
            (void) conn->write(buf, ret);
          }
          delete conn;
        };
      }
    }
  };

  acl::fiber::schedule();  // Start the coroutine scheculde process.
}

4.5. One Http client

#include "acl_cpp/lib_acl.hpp"

bool run(void) {
  acl::http_request conn("www.baidu.com:80");
  acl::http_header& header = conn.request_header()
  header.set_url("/")
    .set_keep_alive(false);
    .set_content_type("text/html");

  if (!conn.request(NULL, 0)) {
    return false;
  }
  int status = conn.http_status();
  if (status != 200) {
    return false;
  }
  long long len = conn.body_length();
  if (len <= 0) {
    return true;
  }
  acl::string buf;
  if (!conn.get_body(body)) {
    return false;
  }
  return true;
}

4.6. Coroutine Http server

#include "acl_cpp/lib_acl.hpp"  // Must before http_server.hpp
#include "fiber/http_server.hpp"

static char *var_cfg_debug_msg;
static acl::master_str_tbl var_conf_str_tab[] = {
  { "debug_msg", "test_msg", &var_cfg_debug_msg },
  { 0, 0, 0 }
};

static int  var_cfg_io_timeout;
static acl::master_int_tbl var_conf_int_tab[] = {
  { "io_timeout", 120, &var_cfg_io_timeout, 0, 0 },
  { 0, 0 , 0 , 0, 0 }
};

int main(int argc, char* argv[]) {
  const char* addr = "0.0.0.0|8194";
  const char* conf = argc >= 2 ? argv[1] : NULL;
  acl::http_server server;

  // Call the methods in acl::master_base class .
  server.set_cfg_int(var_conf_int_tab).set_cfg_str(var_conf_str_tab);

  // Call the methods in acl::http_server .
  server.on_proc_init([&addr] {
    printf("---> after process init: addr=%s, io_timeout=%d\r\n", addr, var_cfg_io_timeout);
  }).on_proc_exit([] {
    printf("---> before process exit\r\n");
  }).on_proc_sighup([] (acl::string& s) {
    s = "+ok";
    printf("---> process got sighup\r\n");
    return true;
  }).on_thread_accept([] (acl::socket_stream& conn) {
    printf("---> accept %d\r\n", conn.sock_handle());
    return true;
  }).Get("/", [](acl::HttpRequest&, acl::HttpResponse& res) {
    std::string buf("hello world1!\r\n");
    res.setContentLength(buf.size());
    return res.write(buf.c_str(), buf.size());
  }).Post("/json", [](acl::HttpRequest& req, acl::HttpResponse& res) {
    acl::json* json = req.getJson();
    if (json) {
      return res.write(*json);
    } else {
      std::string buf = "no json got\r\n";
      res.setContentLength(buf.size());
      return res.write(buf.c_str(), buf.size());
    }
  }).run_alone(addr, conf);

  return 0;
}

4.7. One redis client

#include <thread>
#include "acl_cpp/lib_acl.hpp"

static void thread_run(acl::redis_client_cluster& conns) {
  acl::redis cmd(&conns);
  std::map<acl::string, acl::string> attrs;
  attrs["name1"] = "value1";
  attrs["name2"] = "value2";
  attrs["name3"] = "value3";
  acl::string key = "hash-key-1";
  if (!cmd.hmset(key, attrs)) {
    printf("hmset error=%s\r\n", cmd.result_error());
    return;
  }

  attrs.clear();
  if (!cmd.hgetall(key, attrs)) {
    printf("hgetall error=%s\r\n", cmd.result_error());
  }
}

void run(void) {
  const char* addr = "126.0.0.1:6379";
  acl::redis_client_cluster conns;
  conns.set(addr, 0);

  const size_t nthreads = 10;
  std::thread threads[nthreads];
  // Create some threads to test redis using the same conns.
  for (size_t i = 0; i < nthreads; i++) {
    threads[i] = std::thread(thread_run, std::ref(conns));
  }
  // Wait for all threads to exit
  for (size_t i = 0; i < nthreads; i++) {
    threads[i].join();
  }
}

5. More about

5.1. Samples

There are a lot of examples in the acl library for reference, please refer to: SAMPLES.md

5.2. More simple demos

There are many small demos showing how to use acl library easily in Demos

5.3. FAQ

If you have some questions when using Acl, please see FAQ.md.

5.4. License

5.5. Reference

5.6. Thanks

Thanks .

acl's People

Contributors

akzi avatar artamonovevgenii avatar chriscatcp avatar lday0321 avatar loongs-zhang avatar markmeson avatar meihouhao2017 avatar moehuster avatar popsky avatar qazwsxedckll avatar sidyhe avatar soratakasugano avatar waruqi avatar wfeii1980 avatar wkliu19 avatar woodlyer avatar xiaoqiang0 avatar xuchunyang avatar zhengshuxin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acl's Issues

Problems with psubscribe - suite

Following issue "Problems with psubscribe":

Thank you, but the bug is not fixed. psubscribe doesn't work now.
Before, in the redis monitor, I was seeing my command line "PSUBSCRIBE" "*".
Now, there is nothing in the monitor, it seems that the client does not send the request anymore on psubscribe.

Thank you

ACL3.4中redis效率问题

我通过压力测试,发现ACL3.4的redis效率很低,我改成ACL3.3版本就解决了问题,你们是否遇到过类似的问题,难道在3.4中需要有什么开关配置或者使用上有区别?

[redis][renamenx] check please

os : windows 10
version : 3.4.1

In Redis, 'rename' command returns simple_string and 'renamenx' command returns integer value. But In ACL Library, both of 'rename' and 'renamenx' function return the value of bool type.
is this correct? I think that 'renamenx' function should return interger value.

release acl-acl.3.4.0.rc3 windows vs2013 acl_cpp动态库编译失败

acl 和protocol 编译正常, 但是在编译acl_cpp 时出现了如下错误:

 正在创建库 C:/Users//Desktop/cppredis/acl-acl.3.4.0.rc3/mybuild/lib/Release/acl_cpp.lib 和对象 C:/Users/Desktop/cppredis/acl-acl.3.4.0.rc3/mybuild/lib/Release/acl_cpp.exp
3>stdin_stream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>stdout_stream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>stream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>win_iconv.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>polarssl_conf.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>polarssl_io.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>server_socket.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>socket_stream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>ifstream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>istream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>ofstream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>ostream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>aio_stream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>aio_timer_callback.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>aio_timer_delay_free.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>fstream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>aio_istream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>aio_listen_stream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>aio_ostream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>aio_socket_stream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)
3>zlib_stream.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall acl::db_mysql::rollback(void)" (?rollback@db_mysql@acl@@UAE_NXZ)

链接器附加依赖库acl和protocol都已添加
预处理器定义也未改动

WIN32
_WINDOWS
NDEBUG
ACL_WRITEABLE_CHECK
ACL_PREPARE_COMPILE
CMAKE_INTDIR="Release"
protocol_EXPORTS

是我这里配置还有什么问题吗 我是用cmake 生成的解决方案。直接用工程里面的解决方案acl_cpp也有同样的问题。

redis cluster client core in acl

We used acl as clients to visit our redis cluster but in the performance test, we got segment fault and the stack trace is as follwoing.
#0 0x0000000000602c7b in acl::redis_client_cluster::set_slot (this=0x1e2cf10, slot=14780,

addr=0x20 <Address 0x20 out of bounds>) at src/redis/redis_client_cluster.cpp:88

#1 0x0000000000608b86 in acl::redis_command::run (this=0x7f81315ec500, cluster=0x1e2cf10, nchild=0)

at src/redis/redis_command.cpp:448

#2 0x000000000060932b in acl::redis_command::get_number (this=, success=0x0)

at src/redis/redis_command.cpp:603

It seems that the argument addr passed to set_slot is invalid. Our program runs in multi-thread environment, not sure if this is related.

Thanks.

编译失败

/tmp/acl-master/lib_acl/src/stdlib/common/acl_hash.c:500:4: note: in expansion of macro ‘HASHC’
HASHC;
^~~~~
/tmp/acl-master/lib_acl/src/stdlib/common/acl_hash.c:501:2: note: here
case 3:
^~~~
/tmp/acl-master/lib_acl/src/stdlib/common/acl_hash.c:484:17: error: this statement may fall through [-Werror=implicit-fallthrough=]
#define HASHC n = *k++ + 65599 * n
~~^~~~~~~~~~~~~~~~~~

gcc --version
gcc (GCC) 8.1.1 20180531
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

在高版本clang/gcc中,需要加入-Wno-implicit-fallthrough

另外,这个文件涉及到中文注释是gbk编码的,最好还是转成utf-8比较好

在 lib_acl/Makefile 文件中有针对 gcc 版本的判断,如下:
ifeq ($(findstring gcc, $(CC)), gcc)
CFLAGS += -Wstrict-prototypes
GCC_VERSION=$(shell gcc --version | grep ^gcc | sed 's/^.* //g')
GCC_MAJOR:=$(shell echo "$(GCC_VERSION)" | cut -d'.' -f1)
GCC_MINOR:=$(shell echo "$(GCC_VERSION)" | cut -d'.' -f2)
GCC_SUB:=$(shell echo "$(GCC_VERSION)" | cut -d'.' -f3)
GCC_VER:=$(shell [ $(GCC_MAJOR) -gt 4 -o ( $(GCC_MAJOR) -eq 4 -a $(GCC_MINOR) -gt 4 ) ] && echo true)
ifeq ($(GCC_VER), true)
CFLAGS += -Wno-implicit-fallthrough
endif
endif

针对字符集编码问题,主要是为了兼容 VC,VC 针对 UTF8 要求得要有 BOM,所以目前暂时还是采用 GBK 编码,你可以使用一些工具,如 iconv 进行字符集转换

我用的cmake 。。可能这个和Makefile的配置还不太一样

cmake 也支持了,你可以试一下.

acl::redis_client destructor

Calling the destructor on acl::redis_client crashes:


        const char* redis_addr = "127.0.0.1:6379";
    int conn_timeout = 10, rw_timeout = 10;

    // the redis client connection
    acl::redis_client *conn = new acl::redis_client(redis_addr, conn_timeout, rw_timeout);
    delete conn;

redis_list::lpop & rpop返回值与头文件中的注释不符

acl::redis_list command;
redis.set_cluster(command);

int n = command.rpush("test_list", "value1", "value2", NULL);
EXPECT_EQ(n, 2);

acl::string str;
n = command.lpop("test_list", str);
EXPECT_EQ(n, 1);
EXPECT_EQ(str, "value1");

command.lpop返回值期望1,实际6。

Crashed in brpoplpush

Report for xx.exe.4952.dmp
Type of Analysis Performed Crash Analysis
Machine Name
Operating System Windows Server 2008 Service Pack 2
Number Of Processors 4
Process ID 4952
Process Image
System Up-Time 00:00:00
Process Up-Time 1 day(s) 00:05:49

Thread 0 - System ID 5032

Full Call Stack

Function Arg 1 Arg 2 Arg 3 Arg 4 Source
ntdll!RtlReportCriticalFailure+5b c0000374 77a87350 0043f288 77a4be77
ntdll!RtlpReportHeapFailure+21 00000002 b123adaf 00512bc8 00512bd8
ntdll!RtlpLogHeapFailure+a1 00000003 004c0000 00512bd8 00000000
ntdll!RtlpCoalesceFreeBlocks+4b9 004c0000 00512bd8 0043f378 00000000
ntdll!RtlpFreeHeap+1e2 00512bc8 00512bd0 02afa5e8 00512bd0
ntdll!RtlFreeHeap+14e 004c0000 00000000 00512bc8 00000001
kernel32!FormatMessageA+1aa 00000000 00000000 000003e5 00000000
lib_acl!acl_strerror+29 000003e5 02afa5e8 00000080 02afa588
lib_acl!acl_vstream_init+1dc 0043f574 0043f484 00000000 0043f490
lib_acl!acl_vstream_read+92 02afa588 0043f4bf 00000001 0043f96c
lib_acl_cpp!acl::istream::read+75 0043f4bf 00000001 00000000 02b1eb08
lib_acl_cpp!acl::istream::read+1e 0043f4bf cccccccc cccccccc 2acccccc
lib_acl_cpp!acl::redis_client::get_redis_object+2c 009eb088 cccccccc 00cccccc 02b1eae8
lib_acl_cpp!acl::redis_client::run+15e 009eb088 009dbb28 00000000 0043f5a4
lib_acl_cpp!acl::redis_command::run+9c 00000000 cccccccc 0043f5a4 0043f574
lib_acl_cpp!acl::redis_command::get_string+21 0043f5f4 00000010 cccccccc cccc0032
lib_acl_cpp!acl::redis_list::brpoplpush+b7 009db9e8 009dba10 00000002 0043f5f4
! ::Listen+1be 02b1eae8 000000e8 000000f0 7c78d356 d:\scottgu\src\ \ .cpp @ 1686

Ignore more Irrelevant files

The repo is about 106M:

➜  acl git:(master) du -sh
106M    .

I think It's unnecessary to let Git to track library files, i.e. *.dll for WIN, *.a" for Linux, and in addition IDE specific project configure files like acl_vc2003.sln should be ignored too.

协程收包与tcp抓包的顺序偶尔乱序

image
在不可重现的极端app弱网情况下,后端svr用多线程+协程的方式, while读取 socket_stream::read(buff, size), 出现抓到第一个包延迟10多秒才收到,并且抓到的第二个包协程先收到并处理, 出现app应用异常,
流量不大, 现在已经通过应用层sequence 来解决。 但是没有从根本上解决消息先后乱序的异常,是否协程调度有影响?
出现这种情况的条件是:app 发起第一个socket并请求,然后超时close socket,然后并重新发起socket连接。
结果是: 后端协程服务器并未按照次序接受,且第一次socket延迟10多秒才收到握手,求解。

Problems with psubscribe

Hi,

I'm trying to use the following code and I am not receiving any of the published messages.
What's more the method publish() returns me 1 (as only one connection is listening to the channel).
Do you know why it's not working ? A bug or something wrong on my side ?
Many thanks

 // subscribe
    acl::redis_client connection(_redis_addr);
    acl::redis_pubsub sub(&connection);
    const char* pattern = "*";
    int out = sub.psubscribe(pattern, NULL);

    // then listen
    while(!_stop) {
      acl::string channel, message;
      if(sub.get_message(channel, message)) {
          do stuff ...
     }
  }

hgetall

Hey,
I have to include method for hgetall in your sample file "redis_client_cluster.cpp". How should I do?

redis:subscribe接口导致程序崩溃bug

//redis.subscribe多运行几次,必现
redis_pubsub::subop
{
const char** argv = (const char**) dbuf_->dbuf_alloc(argc * sizeof(char*));
...略略略...
run{!!!may free argv}
check_channel(argv[0]) //argv已被free导致程序崩溃
}
最开始run里面不会清楚内存池,会导致内存泄露
后续加了,这个波及到了

redis_auth死循环问题

我们使用ACL库连接REDIS服务器,REDIS服务器前有haproxy做反向代理。
当REDIS服务器未启动时,执行任意redis命令,会导致死循环。
初步判断是由于haproxy的特性,当后端redis不存在时,redis_client可以成功建立TCP链,但无法执行auth命令。于是陷入建链和认证的死循环。

调用栈如下:

#16873 0xf6ec78fe in acl::redis_client::open (this=0x8a09f10) at src/redis/redis_client.cpp:75
#16874 0xf6ec875b in acl::redis_client::run (this=0x8a09f10, pool=0xab9a3e8, req=..., nchildren=0) at src/redis/redis_client.cpp:324
#16875 0xf6ec48c6 in acl::redis_command::run (this=0xff974ef4, nchild=0) at src/redis/redis_command.cpp:643
#16876 0xf6ec4ff4 in acl::redis_command::check_status (this=this@entry=0xff974ef4, success=success@entry=0xf6f29462 "OK") at src/redis/redis_command.cpp:757
#16877 0xf6ec9198 in acl::redis_connection::auth (this=this@entry=0xff974ef0, passwd=0x89dccd0 "test") at src/redis/redis_connection.cpp:44
#16878 0xf6ec78fe in acl::redis_client::open (this=0x8a09f10) at src/redis/redis_client.cpp:75
#16879 0xf6ec875b in acl::redis_client::run (this=0x8a09f10, pool=0xab98260, req=..., nchildren=0) at src/redis/redis_client.cpp:324
#16880 0xf6ec48c6 in acl::redis_command::run (this=0xff975074, nchild=0) at src/redis/redis_command.cpp:643
#16881 0xf6ec4ff4 in acl::redis_command::check_status (this=this@entry=0xff975074, success=success@entry=0xf6f29462 "OK") at src/redis/redis_command.cpp:757
#16882 0xf6ec9198 in acl::redis_connection::auth (this=this@entry=0xff975070, passwd=0x89dccd0 "test") at src/redis/redis_connection.cpp:44
#16883 0xf6ec78fe in acl::redis_client::open (this=0x8a09f10) at src/redis/redis_client.cpp:75
#16884 0xf6ec875b in acl::redis_client::run (this=0x8a09f10, pool=0xab960d8, req=..., nchildren=0) at src/redis/redis_client.cpp:324
#16885 0xf6ec48c6 in acl::redis_command::run (this=0xff9751f4, nchild=0) at src/redis/redis_command.cpp:643
#16886 0xf6ec4ff4 in acl::redis_command::check_status (this=this@entry=0xff9751f4, success=success@entry=0xf6f29462 "OK") at src/redis/redis_command.cpp:757
#16887 0xf6ec9198 in acl::redis_connection::auth (this=this@entry=0xff9751f0, passwd=0x89dccd0 "test") at src/redis/redis_connection.cpp:44
#16888 0xf6ec78fe in acl::redis_client::open (this=0x8a09f10) at src/redis/redis_client.cpp:75

publish return 0, but there is peer listening and peer seems do receive the message

Hi,

There is a redis cluster, and I use redis client redis-cli to subscribe to certain channel.

Then I use acl redis publish command to publish to the channel, but the result is unexpected,
it returns 1 for one time, then 0 for the next time, then continue in this 1 0 1 0 ... pattern.

And actually redis-cli displays all messages, so I would expect all return 1, why some not?

Any idea?

Thanks

support mingw on windows?

I make lib_acl with mingw on windows there're compile errors.
so please support optional compilation with mingw on windows.

build error LNK2001: unresolved external symbol "public: virtual __thiscall acl::string::~string(void)"

should be acl version 87, 修改历史列表:--87) 2015.5.21


source code in error:

const char* cmd = "ZREM"; 
std::vector<acl::string> args;
m_transaction.clear();
args.clear();

cmd = "ZREM";
args.push_back(GlobalRedisKeys::Instance()->m_key_zsetRegion.c_str());
args.push_back(cross_region_key.c_str());
if (m_transaction.run_cmd(cmd, args) == false) { //remove from  zset
    ROOT_LOGGER->error("redis: run cmd error! cmd: ZREM " + GlobalRedisKeys::Instance()->m_key_zsetRegion);
    return false;
}

ERROR:

RMBussinessLogic.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall acl::string::~string(void)" (??1string@acl@@UAE@XZ)

ACL线程池acl_pthread_pool_t工作线程有阻塞和超时机制吗

线程池中的工作线程是否存在运行超时提前被强制结束的情形:
1.acl_pthread_pool_set_schedule_warn,如果设置了该值,线程调度时间超过此值仅仅是生成警告日志吗?会不会如题所述强制结束工作线程;
2.acl_pthread_pool_set_schedule_wait,该函数是否也跟如题所述问题有关?

Windows10 Visual Studio 2017下编译出错

严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK1104 无法打开文件“lib_acl_vc2012d.lib” mime_qp E:\迅雷下载\acl-master\lib_acl_cpp\samples\mime\mime_qp\LINK 1
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK1104 无法打开文件“lib_acl_d.lib” HttpClient E:\迅雷下载\acl-master\lib_acl_cpp\samples\HttpClient\LINK 1
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK1104 无法打开文件“lib_acl_cpp_d.lib” win_dbservice E:\迅雷下载\acl-master\lib_acl_cpp\samples\win_dbservice\LINK 1
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK1104 无法打开文件“lib_acl_d.lib” winaio E:\迅雷下载\acl-master\lib_acl_cpp\samples\winaio\LINK 1
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK1104 无法打开文件“polarssl.lib” ssl_client E:\迅雷下载\acl-master\lib_acl_cpp\samples\ssl\ssl_client\LINK 1
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 C3848 具有类型“const server_ttl_comp”的表达式会丢失一些 const-volatile 限定符以调用“bool server_ttl_comp::operator ()(const server_ttl *,const server_ttl *)” dispatch_manager d:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\xutility 946
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 C1189 #error: MFC does not support WINVER less than 0x0501. Please change the definition of WINVER in your project properties or precompiled header. winaio_vc2012 d:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\atlmfc\include\afxv_w32.h 40

File in repository triggered virus scan

Hi,

I'd like to raise your attention to a particular text file in your repository, which upon cloning, triggered my antivirus.
It appears to be a zip file encoded in base64 (attachment of that sample email).
If that file is decoded back into a zip file and then uncompressed, it appears to contain a trojan.

This is the file.

I hope this file can be scrubbed from the git history so that unsuspecting users will not accidentally unleash a trojan upon themselves.

redis load脚本崩溃(3.4.0版本)

/opt/mcu/sodir/librediswrap.so(acl_default_free+0x8b) [0x5626873b]
/opt/mcu/sodir/librediswrap.so(acl_free_glue+0x3c) [0x56246bac]
/opt/mcu/sodir/librediswrap.so(acl_array_free+0x5f) [0x5624bf0f]
/opt/mcu/sodir/librediswrap.so( +0xf3) [0x56242613]
/opt/mcu/sodir/librediswrap.so(_ZN3acl6stream5closeEv+0x56) [0x5622cf96]
/opt/mcu/sodir/librediswrap.so(_ZN3acl12redis_client5closeEv+0x2e) [0x5620551e]
/opt/mcu/sodir/librediswrap.so(_ZN3acl12redis_client3runEPNS_9dbuf_poolERKNS_6stringEjPi+0x60) [0x56206130]
/opt/mcu/sodir/librediswrap.so(_ZN3acl13redis_command3runEjPi+0xf1) [0x5620cd61]
/opt/mcu/sodir/librediswrap.so(_ZN3acl13redis_command10get_stringERNS_6stringE+0x2c) [0x5620d5ac]
/opt/mcu/sodir/librediswrap.so(ZN3acl12redis_script11script_loadERKNS_6stringERS1+0xa2) [0x5621abb2]
/opt/mcu/sodir/librediswrap.so(_ZN10CRedisWrap17LoadScriptContentEPKcRSs+0x68) [0x561fff08]
崩溃堆栈如上
其他信息:
. 触发的SIGABRT信号
. 程序是多线程模型,每个redis操作已加锁保护

文件编码问题,想转成utf-8

file json.hpp
json.hpp: C++ source text, ISO-8859 text, with CRLF line terminators

iconv -l | grep 8859
CP819 IBM819 ISO-8859-1 ISO-IR-100 ISO8859-1 ISO_8859-1 ISO_8859-1:1987 L1 LATIN1 CSISOLATIN1
ISO-8859-2 ISO-IR-101 ISO8859-2 ISO_8859-2 ISO_8859-2:1987 L2 LATIN2 CSISOLATIN2
ISO-8859-3 ISO-IR-109 ISO8859-3 ISO_8859-3 ISO_8859-3:1988 L3 LATIN3 CSISOLATIN3
ISO-8859-4 ISO-IR-110 ISO8859-4 ISO_8859-4 ISO_8859-4:1988 L4 LATIN4 CSISOLATIN4
CYRILLIC ISO-8859-5 ISO-IR-144 ISO8859-5 ISO_8859-5 ISO_8859-5:1988 CSISOLATINCYRILLIC
ARABIC ASMO-708 ECMA-114 ISO-8859-6 ISO-IR-127 ISO8859-6 ISO_8859-6 ISO_8859-6:1987 CSISOLATINARABIC
ECMA-118 ELOT_928 GREEK GREEK8 ISO-8859-7 ISO-IR-126 ISO8859-7 ISO_8859-7 ISO_8859-7:1987 ISO_8859-7:2003 CSISOLATINGREEK
HEBREW ISO-8859-8 ISO-IR-138 ISO8859-8 ISO_8859-8 ISO_8859-8:1988 CSISOLATINHEBREW
ISO-8859-9 ISO-IR-148 ISO8859-9 ISO_8859-9 ISO_8859-9:1989 L5 LATIN5 CSISOLATIN5
ISO-8859-10 ISO-IR-157 ISO8859-10 ISO_8859-10 ISO_8859-10:1992 L6 LATIN6 CSISOLATIN6
ISO-8859-11 ISO8859-11 ISO_8859-11
ISO-8859-13 ISO-IR-179 ISO8859-13 ISO_8859-13 L7 LATIN7
ISO-8859-14 ISO-CELTIC ISO-IR-199 ISO8859-14 ISO_8859-14 ISO_8859-14:1998 L8 LATIN8
ISO-8859-15 ISO-IR-203 ISO8859-15 ISO_8859-15 ISO_8859-15:1998 LATIN-9
ISO-8859-16 ISO-IR-226 ISO8859-16 ISO_8859-16 ISO_8859-16:2001 L10 LATIN10

都没法转换,用的什么编辑器这么奇怪的文件编码,能写个脚本把所有文件都转成utf-8吗?

arm_v5t4_le-gcc交叉编译lib_acl的问题。

main函数使用 -acl的方式链接动态库 libacl.so。在libtool: link的时候出现
libacl.so: undefined reference to '__tync_lock_test_and_set_8'
libacl.so: undefined reference to '__sync_fetch_and_add_8'
libacl.so: undefined reference to '__sync_fetch_and_fetch_8'
但是使用-acl的方式链接静态库却没有出现上述错误。动态库有问题,静态库没有问题。

目前还没找到解决办法。麻烦帮忙看一下大概有什么解决方法。

redis blpop 执行几次就必然crash

[New LWP 15714]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./cici-server'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: 没有那个文件或目录.
(gdb) bt
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x00007f8a24511672 in acl::redis_list::bpop (
this=this@entry=0x7ffeeb82d0f0, cmd=cmd@entry=0x7f8a245588cd "BLPOP",
keys=std::vector of length 12, capacity 16 = {...},
timeout=timeout@entry=1, result=...)
at /_dev/server/external/acl/lib_acl_cpp/src/redis/redis_list.cpp:372
#2 0x00007f8a24511765 in acl::redis_list::blpop (
this=this@entry=0x7ffeeb82d0f0,
keys=std::vector of length 12, capacity 16 = {...},
timeout=timeout@entry=1, result=...)
at /_dev/server/external/acl/lib_acl_cpp/src/redis/redis_list.cpp:319
#3 0x00007f8a2451187e in acl::redis_list::blpop (this=0x7ffeeb82d0f0,
result=..., timeout=1,
first_key=0x42e982 <typeinfo name for cici::ci_restful::start(cici::ci_conf&)::{lambda(int)#1}+34> "confEEUliE")
at /_dev/server/external/acl/lib_acl_cpp/src/redis/redis_list.cpp:313
#4 0x000000000041cb6d in cici::ci_service::start(cici::ci_conf&) ()
#5 0x00007f8a239aa150 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007f8a239aa160 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x9e8e2a78cdcc0900 in ?? ()
#8 0x00007f8a2545df80 in ?? ()
#9 0x00007f8a239a8f40 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#10 0x00007ffeeb82d370 in ?? ()
---Type to continue, or q to quit---

UDP 服务器 遇到 UDP连接请求导致停止服务

服务端是dgate 中,端口53, UDP 接收, 客户端采用HP-SOCKET 的TestEcho-UDP-Client.exe, 客户端发起UDP连接, dgate中 ret = recvfrom(fd, ......); 返回-1,UDP接收就失效,必须重启程序。
意味着简单的攻击就可以使UDP服务器挂掉。

Ubuntu 16.04 下编译失败

我在自己的项目中引入acl时,编译出错。
C++11, 在cmakelist文件里添加如下:

add_subdirectory(thirdparty/acl/lib_acl acl) add_subdirectory(thirdparty/acl/lib_protocol protocol) add_subdirectory(thirdparty/acl/lib_acl_cpp acl_cpp)

引入acl, protocol, acl_cpp三个库

然后链接到我的项目
target_link_libraries(.... acl protocol acl_cpp)

但是make的时候报错:
cd /home/machine1/tmp/myproject/build/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/myproject-unittests.dir/link.txt --verbose=1 /usr/bin/c++ CMakeFiles/myproject-unittests.dir/main.cpp.o CMakeFiles/myproject-unittests.dir/worker/worker_unittest.cpp.o CMakeFiles/myproject-unittests.dir/worker/worker_manager_unittest.cpp.o -o ../../bin/myproject-unittests -rdynamic -lboost_date_time -lboost_chrono -lboost_filesystem -lboost_serialization -lboost_program_options -lboost_regex -lboost_system -lboost_thread -lpthread ../../lib/libgtest.a ../../lib/libgtest_main.a ../../lib/libgmock.a ../../lib/libgmock_main.a ../lib/libacl_cpp.so /usr/local/lib/libzmq.so /usr/local/lib/libczmq.so ../../lib/libgtest.a -lpthread ../lib/libprotocol.so ../lib/libacl.so -Wl,-rpath,/home/machine1/tmp/myproject/build/lib:/usr/local/lib ../lib/libacl_cpp.so: undefined reference to deflateInit2_'
../lib/libacl_cpp.so: undefined reference to deflate' ../lib/libacl_cpp.so: undefined reference to deflateEnd'
../lib/libacl_cpp.so: undefined reference to crc32' ../lib/libacl.so: undefined reference to dlopen'
../lib/libacl_cpp.so: undefined reference to inflate' ../lib/libacl_cpp.so: undefined reference to inflateInit2_'
../lib/libacl_cpp.so: undefined reference to inflateEnd' ../lib/libacl.so: undefined reference to dlclose'
../lib/libacl.so: undefined reference to dlerror' ../lib/libacl.so: undefined reference to dlsym'
collect2: error: ld returned 1 exit status`

在MacOS下一摸一样的代码可以正确编译使用,但是ubuntu系统下无法编译通过。
已经在3台MacOS电脑,3台Ubuntu16.04电脑下测试。

redis sub redis.get_message read data error

代码如下

#include "acl_cpp/lib_acl.hpp"

int main(int argc, char * argv[])
{
    acl::acl_cpp_init();
    acl::log::stdout_open(true);


    acl::string redis_addr("127.0.0.1:6379");

    int  conn_timeout = 10, rw_timeout = 10;


    acl::redis_client client(redis_addr, conn_timeout, rw_timeout);

    acl::redis_pubsub redis;

    redis.set_client(&client);
    redis.clear();
    acl::string channel = "md";
    redis.subscribe(channel,NULL);

    acl::string msg;

    channel.clear();
    msg.clear();
    redis.clear();

    while(true){
        if ((redis.get_message(channel, msg)) == false)
        {
            printf("get_message error(%s)\r\n",
                   redis.result_error());
            //return false;
        }
        else
        {
            printf("message: %s, channel: %s\r\n",
                   msg.c_str(), channel.c_str());
        }
    }


    return 0;
}

acl::string.format("%u", uint64) issue

Boost::uint64_t timeInMs=1446202713817;
acl::string recvTimeInMilliSec;
recvTimeInMilliSec.format("%u", timeInMs); 
//recvTimeInMilliSec== "3093702361"

master服务器下的master_ctld服务进程频繁重启

make install 后,利用acl\dist\master下安装脚本,会自动将几个acl\app\master\tools几个工具考到libexec\目录下,运行后发现master_ctld服务被启动后会自动退出,被master进程反复重启,经过分析发现,启动服务时参数带入了‘-v’选项,而app\master\tools\master_ctld\main\main.c中check_version()函数在判断-v时会调用exit()。

redisClient在MFC中不能释放

1 如果用DEMO中的
acl::redis_client client (addr.c_str(), conn_timeout, rw_timeout);
刚只在当前函数中有效,无法在其他部分使用。

2 所以采用指针, acl::redis_client* client;
然后 client = new acl::redis_client(addr.c_str(), conn_timeout, rw_timeout);
但这样 delete client无效,delete 之后,还是内存泄露。

3 上面delete之后,立即引起程序崩溃。应该是底层哪里对内存有影响。

4 console模式下没问题。MFC下根本不能用。

Chinese messy code -- some source code files contains Chinese characters in ansi

/**
 * µ±ÈÎÎñ´¦ÀíÍê±Ï»ò³ö´íʱ£¬ÄÚ²¿´¦Àí¹ý³Ì»á×Ô¶¯µ÷Óà destroy ½Ó¿Ú£¬
 * ×ÓÀà¿ÉÒÔÔڸýӿÚÄÚ½øÐÐһЩÊͷŹý³Ì£¬ÓÈÆäµ±¸Ã¶ÔÏóÊǶ¯Ì¬´´½¨Ê±£¬
 * ×ÓÀàÓ¦¸ÃÔڸú¯ÊýÄÚ delete this ÒÔɾ³ý×Ô¼º£¬ÒòΪ¸Ãº¯Êý×îÖտ϶¨
 * »á±»µ÷Óã¬ËùÒÔ×ÓÀ಻ӦÔÚÆäËüµØ·½½øÐÐÎö¹¹²Ù×÷
 */

if set it to ansi, it will be messy code on another computer which using another language.

libfiber

libfiber不支持kqueue所以BSD环境下不能使用(比如mac)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.