FISCO-BCOS / bcos-c-sdk

c-style sdk for FISCO-BCOS 3.0
Apache License 2.0
2 stars 12 forks source link

use bcos_sdk_create to create and start sdk costing 100% cpu with empty run #221

Open Keyon11 opened 8 months ago

Keyon11 commented 8 months ago

Describe the bug I modify hello_sample.c with following code found that program always costing 100% cpu when sleep waiting for free sdk.

    // 1. create sdk object by config
    void* sdk;
    if (strlen(config) == 0) {
        struct bcos_sdk_c_config* cfg = bcos_sdk_create_config(1, "172.25.0.3", 20210);
        sdk = bcos_sdk_create(cfg);
    } else {
        sdk = bcos_sdk_create_by_config_file(config);
    }
   ... 
  sleep(300);
 //before bcos_sdk_c_free

To Reproduce Steps to reproduce the behavior:

  1. check out branch main
  2. modify hello_sample.c as above and fix host:port
  3. compile and run hello_sample
  4. use command 'top' to see hello_sample cpu cost

Expected behavior no empty run cost

Screenshots none

Environment (please complete the following information):

Additional context none

kyonRay commented 8 months ago

Mentioned in https://github.com/FISCO-BCOS/bcos-c-sdk/pull/222