Zookeeper C API Single threaded and multithreaded issues Cli_st and CLI_MT

Source: Internet
Author: User

The same procedure, both on CentOS and Ubuntu, has a lot of problems with Solaris, which is said to be more stringent in Solaris management.

Zookeeper_init method, the host can also initialize a non-empty handle, only through the state to determine whether the connection.

In addition, the use of ZOOKEEPER_MT on CentOS can be connected to ZK, but not on Solaris.

Analysis of the two tools in src/c Cli_st and CLI_MT, found that CLI_MT is not connected, and Cli_st can be connected. So excitedly will compile options library changed to-lzookeeper_st, the result returned handle non-empty, happy bad, thought success, result ~, status display as connection failure: Error code 999, this is not yet connected performance.

Then began to analyze why the Cli_st tool can be connected, the code/SRC/CLI.C file is nothing special, it should be the problem of the compilation option:

GCC-dhave_config_h-i. -i./include-i./tests-i./generated-d_posix_pthread_semantics-wall-werror-g-O0-D_GNU_SOURCE-MT CLI.O-MD-MP-MF . deps/cli. Tpo-c-o cli.o ' test-f'SRC/CLI.C'||Echo './'' src/CLI.CMV-F. Deps/cli. Tpo. deps/CLI. Po/bin/SH./libtool--TAG=CC--mode=linkGCC-wall-werror-g-o0-d_gnu_source-o cli_st cli.o libzookeeper_st.lalibtool:link:GCC-wall-werror-g-o0-d_gnu_source-o cli_st cli.o./.libs/libzookeeper_st.a-lnsl-lsocket-lm

The first thing to understand is the difference between libzookeeper_mt.so and libzookeeper_st.so:

Zookeeper C client is divided into Mt Library and St Library (multithreading and single thread), the general operation is multi-threaded library mainly.

First record here, and give the results later.

Cause of the problem:

ZK Multi-threaded init is divided into three threads, the main thread, the IO thread and the completion thread, the thread that invokes the API, the IO thread responsible for network traffic, the asynchronous request and watch response, and so on, the IO thread is sent to the completion thread, Done asynchronously by the completion thread:

Http://weakyon.com/2015/11/21/analysis-of-zookeeper-c-client-code.html

A single thread requires you to register Zookeeper_interest:

HTTPS://GITHUB.COM/APACHE/ZOOKEEPER/BLOB/MASTER/SRC/C/SRC/CLI.C 775 Lines

Next we need to see why it's not possible to use multithreading on Solaris

Zookeeper C API Single threaded and multithreaded issues Cli_st and CLI_MT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.